© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
27 replies
keii

Do static classes leak memory?

I have made a simple 2d game engine currently built on SDL2 to work on the api and such. What i've noticed is that the game engine is leaking loads of memory (around 2 mb a second) and i'm trying to figure out why. Now the entire game engine is composed of static classes so that you can do calls like
Draw.Rectangle(x, y, w, h)
Draw.Rectangle(x, y, w, h)
and likewise to ease the learning curve and Draw.Rectangle adds a class to a list which is drawn and cleared every frame. Do static classes not clear memory or something similar or do i have another problem? I have checked the rider memory debugger and it says that the Rectangle class takes up around 255 kb which should not be happening.
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Memory leak : WeakReferences
C#CC# / help
17mo ago
Debugging memory leak
C#CC# / help
17mo ago
❔ dataset memory leak
C#CC# / help
3y ago
❔ Do static two way bindings leak XAML?
C#CC# / help
3y ago