Memory Woes

Hey guys,

So I recently unearthed a project I worked on a while back with hopes of releasing it. Doing some quick testing though, I noticed that it seems to be leaking memory.

So I did some tests, and it’s left me puzzled. I don’t appear to be leaking objects. I’ve got a key mapped to print out

And if I complete some state cycle in the game (main menu->level select->level 1->main menu), then the length of this list is unchanged.

Prodding around some more, I decided to try Panda’s MemoryUsage module. I’m not very sure I’m using it right, but if I print out MemoryUsage.getTotalSize() before and after a state cycle, it stays constant. Despite this, the corresponding python.exe task is steadily increasing. I’m not sure how reliable this actually is since MemoryUsage.isCounting() is returning 0 (even with track-memory-usage set in my Config.prc file).

This happens during levels as well. I left my character running against a wall (disabled sound effects as a test case, as well), and, after a half hour, the program was out of memory, even though, once again, my objects according to the garbage collector and memory according to Panda’s MemoryUsage are not changing.

I’m doing this in Panda 1.6.2, but the same problem exists when I run my project in 1.5.4 and 1.7.0. I don’t know if this is a Panda issue or an issue with my Python code, I’m just having a hard time figuring out what’s going on, so help would be appreciated.

My best guess was that I might have some global array or other collection that keeps growing. It wouldn’t be storing objects, since then the garbage collector’s object count should report that, so it would have to be integers or strings or some other primitive datatype…unless those, too, would be caught by the gc’s object count, I don’t actually know. Haven’t been able to find such a thing, though.

I read in another topic that I could try setting geom-cache-size to 0, but that didn’t work either. Also, since I’ve been mentioning that my changing some variables in my Config file haven’t had any effect, I’ve tweaked other options (like show-frame-rate-meter) and they’ve had the anticipated effect.

I wondered if it was some weird 64 bit thing (I’m on 64 bit Windows 7), but it’s the same on my 32 bit XP machine.

Memory problems always suck. Any suggestions for how to proceed?


gc.get_objects() will not show some of the internal C++ panda3d objects but pstats will. Run your game with pstats and see if any thing is increasing or not? I remember i had a leak with transform cache.