|
Viewing 1 to (4 Total) TextField iOS memory leaks |
Total Posts: 20
Joined: February 20, 2012
|
On iOS, setting the text property of a TextField which has been added to the stage causes memory leaks. The leaked object is an _NSCFString. We are using NME 3.3.0.
For example, this causes memory leaks:
textField = new TextField();
textField.text = 'Testing';
addChild(textField);
...but if either the text property is not set, or the field is not added to the stage, no leaks occur. Of course, both of these things need to be done in order to actually use the TextField.
When profiling, here's what we get: http://prototypes.mourlamstudios.com/winthrop/leaks.jpg
We are almost done with our first iOS app built using NME, and were planning on releasing tomorrow until we ran into this issue. Please help!
Tags:
Posted on April 12, 2012 at 10:43 AM
|
|
|
Total Posts: 152
Joined: February 12, 2012
|
Re: TextField iOS memory leaks
Unfortunately I'm seeing about 50+ leaks just from using the source code on Josh's website here (#3):
http://www.joshuagranick.com/blog/2011/09/15/improvements-around-th...
when profiling for iOS. We're trying to release Mole Word (http://www.ancientsheep.com/mole - sorry for the large file size) tomorrow and were pretty scared when we first saw all the leaks in the profiler but we've narrowed down the hundreds of leaks caused by simple textfields.
I'm going to download nightly build to see if that makes any difference.
Posted on April 12, 2012 at 11:16 AM
|
Total Posts: 2141
Joined: August 25, 2011
|
Re: TextField iOS memory leaks
Do you have any more information what is causing the leak?
If you need to, you might be able to do a workaround where you destroy and recreate the TextField, ratther than changing the text. That might be a quick way to prevent the problem for now, so we can spend more time finding a proper solution
Posted on April 13, 2012 at 7:57 PM
|
Total Posts: 152
Joined: February 12, 2012
|
Re: TextField iOS memory leaks
Thanks for the reply Josh. It's not just a matter of changing the text property thats causing the leak. As soon as a textfield is added to the stage, both the format and the textfield leak. Here is some sample code you posted on your blog:
var font = ApplicationMain.getAsset ("assets/MyCustomFont.ttf");
var format = new TextFormat (font.fontName, 24, 0xFF0000);
var text = new TextField ();
text.defaultTextFormat = format;
text.width = 240;
text.height = 60;
text.embedFonts = true;
text.text = "Hello World";
addChild (text);
Put this in a blank haxe project and profile for iOS. There are 50+ leaks coming from the code above (of course we used our own ttf font). We use textfields quite heavily in our game so there are tons of small leaks (only from textfields and textfieldformats)
I don't think apple will approve an app that leaks.
I believe this will be an issue for ANYONE submitting an app to Apple using TextFields.
Worst-case scenario, is there a simple bitmap font class we can use? I've seen one in gm2d but we're unable to find ANY documentation on using gm2d.
You can download the android version of Mole Word here:
http://beta.mashmyaveragelife.com... - "Mole Word (Android)"
We'll be posting this on the Showcase shortly but we sure are hoping to find a solution so we can submit to Amazon / Google store on Monday and the iOS / Mac store Tuesday. We're anxious to release our first game built using Haxe to android and apple markets!! We've only released Haxe MASH for Facebook so far. We have several top 200 Word games on the Appstore, one Top 10 Word game and we're hoping Haxe Word Mole will do just as well!
Thanks again for your help! Haxe has DRAMATICALLY improved our development time and market reach.
Posted on April 13, 2012 at 11:24 PM
|