简体   繁体   中英

Increase in Memory usage without leak?

I have a program that CRTDBG reports as having no leaks, yet, according to Windows Task Manager takes up more memory as time goes on. Even worse is that given enough time, it will crash with exit code -1.

This is a program that's going to be a game engine, right now I'm testing the functions that will unload the level by making it rapidly load and unload levels. This appears to be working, otherwise the entities from the 'last' level would bump into the current ones. The memory doesn't increase when I run the program 'normally' and load one level without unloading until exiting.

It may be of note that loading a level involves reading from the hard drive and opening a file. It might also be important to know that I'm using the Chipmunk physics library, Lua, and OpenGL.

The thing that's making this the most tricky is how CRTDBG won't dump, and it returns 0 at the end of main().

EDIT: Also, using Visual Studio 2008.

To me it sounds like you are not really leaking memory, just allocating a lot of it and then freeing it up at the exit.

Perhaps you are holding on to some list of objects that you forget to free/delete between the loading of each level ?

It may be that you're observing the effects of a "smart" allocator that asks the OS for big chunks of memory and suballocates. You might check by replacing the global operator new and operator delete . If those tell you that all allocated memory is also deallocated, and yet the process' memory consumption goes up or stays up there, then it's (most probably) the allocator.

Lua's garbage collector collects when it feels like it. If you're not explicitly ordering Lua to do a collection, then memory may build up there without being actually used.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM