pjasicek / OpenClaw

Reimplementation of Captain Claw (1997) platformer
GNU General Public License v3.0
338 stars 39 forks source link

Fixed memory leaks #152

Closed RicoRodriges closed 4 years ago

RicoRodriges commented 4 years ago

I played debugger with profiler and found some memory leak: 1) ActorPrototype_BaseProjectileSpawner and ActorPrototype_Level2_CannonBall has multi definitions. I removed unnecessary xml assets. It produced memory leaks. 2) OpenClaw/CMakeLists.txt has comment. Uncomment it to print heap dump with Visual Studio CRT. It shows source code references to investigate memory leaks. 3) Actors cannot be freed. they have cached PositionComponent. And PositionComponent has an owner. Now it fixed. 4) Fixed big part of leaks with Animation class. 5) Refactored BaseGameApp and ResourceMgr classes. Now BaseGameApp and ResourceMgr frees all resources. Also refactored main loop executor in BaseGameApp class. Game didn't call exit(0) anymore. 6) Fixed some TinyXML resources leaks.

Now heap dumper shows memory leak ~ 40 byte (It's something with EventData_Quit_Game shared pointer). I think it's a win.