Memory leak in Text

  ... in the unlikely case you discovered a bug, post it here.

Memory leak in Text

Postby HexWave » Fri Dec 10, 2010 12:32 pm

Hi,

I noticed a memory leak when creating a large number of Text objects since it creates an internal TextTextureBuffer that prevents GC from cleaning it up. I added the following method to unload the buffer if you need to create new a new Text object often. Using ChangeableText is probably a better solution in most cases though :)

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.        
  2. public void unloadBufferObjects()
  3. {
  4.         BufferObjectManager.getActiveInstance().unloadBufferObject(this.mTextTextureBuffer);
  5.         BufferObjectManager.getActiveInstance().unloadBufferObject(this.getVertexBuffer());
  6. }
  7.  
Parsed in 0.011 seconds, using GeSHi 1.0.8.4


Total heap usage reported in DDMS is sitting around 2.8MB now after 50k new Text/addEntity/unloadBufferObjects loops.

Cheers,
Matt
HexWave
HexWave
 
Posts: 22
Joined: Sat Nov 13, 2010 12:12 am

Re: Memory leak in Text

Postby adobo76 » Thu Jan 20, 2011 3:03 am

I was using something similar to remove laser sprites and everything seems to be working alright. Today, however, I created a menu and on the destroy process I did this and noticed that it was causing corruption in other parts of my game. I'm not sure of the cause. It could be because the sprites or textures were so big. I'm going to post something in the bugs section on this.
adobo76
 
Posts: 84
Joined: Sun Oct 17, 2010 4:14 pm

Re: Memory leak in Text

Postby Ghilt » Tue Aug 14, 2012 1:19 pm

Did a heap dump and it seems i got this problem aswell.

I dont know if andengine got updates on this since then but i cant figure out how to get the buffers. this.getVertexBuffer() and this.mTextTextureBuffer doesn't compile
Ghilt
 
Posts: 27
Joined: Mon Jul 04, 2011 1:46 pm


Return to Bugs

Who is online

Users browsing this forum: No registered users and 6 guests