Narendrabrsoft / cocos2d-android-1

Automatically exported from code.google.com/p/cocos2d-android-1
0 stars 0 forks source link

Fix for CCLabel not freeing texture when setString() called. #83

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Add a CCLabel and some large-ish textures to steal some memory.
2. Call setString( frameCount.tostring() ) on each frame
3. Wait and watch LogCat for below:

What is the expected output? What do you see instead?
-eglLockWindowSurface: failed to map the memory for fd....
-GL error 0x0505
This will generally occur after exactly the same amount of time/frames each 
time you run it.

What version of the product are you using? On what operating system?
Latest source at time of writing, Android 2.33 (Cyanogen), Xperia X10

Please provide any additional information below.

Simple fix in CCLabel.java:

public void setString(CharSequence seq){
        ...
        if (texture_ != null){  texture_.releaseTexture(CCDirector.gl);   }
        ...
}       

I've played around with recycling the existing texture, and changing the scope 
of the bitmap/canvas in initWithtext() - which to some extent does reduce the 
memory issue - but only by about 10% or so without explicitly calling 
gl.glDeleteTextures(1, new int[]{_name}, 0);  at some point.

Original issue reported on code.google.com by wopstic...@gmail.com on 28 Jun 2011 at 4:38