It is currently Tue Aug 11, 2020 9:38 pm


All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: [Resolved]: Possible Memory Leak
PostPosted: Thu Sep 08, 2011 3:35 pm 

Joined: Thu Sep 08, 2011 2:19 pm
Posts: 1
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.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Possible Memory Leak
PostPosted: Thu Sep 08, 2011 8:31 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
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.


Top
Offline Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Theme created StylerBB.net