Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views


Sign in to follow this  






SOMEWHERE I have a memory leak, and I can't for the life of me track it down!

I'm working a bit on Squarediana Jones/SnakeEngine[Scarlet], and among one of them there is a very tiny memory leak, and it is driving me crazy!

Maybe I need better tools, but I don't know what.

Right now all I do is the lame bring up task manager and watch if memory usage goes up.

Once every few times I reload a level (the only level I currently have) memory usage goes up (4 - 8k).

I've tracked it down to when I create new Treasures and WhipHooks (they'll both do it).

Now I can't for the life of me find anything I'm newing and not deleting. I've tried using a giant picture for the sprite to see if that increases how much memory goes up, it doesn't change.

I've tried adding huge double arrays to the whiphooks/treasures themselves, doesn't change it (well, the initial memory usage is way higher, but the increase isn't changed).

I've tried adding huge double arrays to the sprite class, no change.

Basically all that I'm making are simple classes that have sprite classes. It's so simple I figured it would have to be in the Sprite class or Scarlet somewhere, but holy crap I don't know where.

Maybe adding giant arrays to things isn't the most elegant way of tracking down things like this, but I'm not sure what else to do...

So yeah, I'm at a loss
Sign in to follow this  


Recommended Comments

Its probably something like a copy constructor not correctly passing ownership of a resource, thus losing the handle on that memory handle.

Do your classes have raw pointers to memory allocated with new? Do all such classes have proper copy/assignment operators which will free the old stuff, etc, as necessary? This is especially required with using STL stuff, which very commonly call the copy constructor to move your stuff around in memory.

Share this comment

Link to comment
Could be, but now I added an inline function to my texture manager just to check how many textures were loaded, and now nothing works. Now classes with just primitives aren't being properly constructed, and they have empty constructors. I think god hates me.
If I ever get this figured out I'll look in to that though, thanks.

Share this comment

Link to comment
I'm pretty sure there are utilities for Visual Studio that catch memory leaks, I just never used any of them because I never found a bug so crippling that I saw the need to do that. But yeah, you should try it, sorry I can't point you in the right direction though :)

Share this comment

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!