Volumes Of Fun http://www.volumesoffun.com/phpBB3/ |
|
[Resolved]: Possible Memory Leak http://www.volumesoffun.com/phpBB3/viewtopic.php?f=15&t=261 |
Page 1 of 1 |
Author: | Kaze [ Thu Sep 08, 2011 3:35 pm ] |
Post subject: | [Resolved]: Possible Memory Leak |
Hello, i had a memory leak in my program and after a long search tracked it back to PolyVox LargeVolume. At this point i must say i am pretty new to c++, (Ogre) and PolyVox, so i probably dont understand every design decision. If i'm wrong, maybe just send me a PM and delete this topic to avoid confusion. i wrote a simple test case: Code: for(int i = 0; i < 10000; i++){ PolyVox::Region* region = new PolyVox::Region(PolyVox::Vector3DInt32(0,0,0), PolyVox::Vector3DInt32(31, 31, 31)); PolyVox::LargeVolume<PolyVox::Material8>* volumeData = new PolyVox::LargeVolume<PolyVox::Material8>(*region,0,0,false,(uint16_t)32U); delete region; delete volumeData; } // memory ~300MB at this point boost::this_thread::sleep(boost::posix_time::milliseconds(5000)); for(int i = 0; i < 10000; i++){ PolyVox::Region* region = new PolyVox::Region(PolyVox::Vector3DInt32(0,0,0), PolyVox::Vector3DInt32(31, 31, 31)); PolyVox::LargeVolume<PolyVox::Material8>* volumeData = new PolyVox::LargeVolume<PolyVox::Material8>(*region,0,0,false,(uint16_t)32U); delete region; delete volumeData; } // memory ~600MB at this point after half of execution memory usage (in window task manager) is at around 300mb, after full execution at 600mb. i searched around and found in LargeVolume.inl the variable m_pUncompressedBorderData being allocated, but not deallocated during destructor execution. so i changed the destructor to: Code: template <typename VoxelType> LargeVolume<VoxelType>::~LargeVolume() { flushAll(); delete m_pUncompressedBorderData; } After that the memory leak is gone, as fas as i can tell. But like i said above, i dont really know PolyVox well, if this is intentional (maybe needed for any kind of operation) or there is another way to clean up(i didnt find one), let me know. |
Author: | David Williams [ Thu Sep 08, 2011 8:31 pm ] |
Post subject: | Re: Possible Memory Leak |
Yep, that's a bug, thanks for catching it. There were a couple of similar examples in SimpleVolume which I also fixed. At some point I'm still intending to build with Valgrind to try and catch any remaning issues. |
Page 1 of 1 | All times are UTC |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |