250+ CCLabelTTF Crashes the App


I am using Cocos2dx for creating an application which at times have need of around 450 Labels in 1 Scene.
When my application crosses 230 to 240 it crashes. In case of Dynamically loading the CCLabelTTF.
In case of statically applying 300 CCLabelTTF it doesnt allow the application to start.

I have used Micromax Funbook alpha for testing also few other higher end devices. It crashes on almost all of them.
In windows it works fine.

Need help on this.


Try using CCLabelBMFont. IMO, 450 labels are too much to handle for most of devices. What sort of application are you making? Any chances to load and destroy or reuse the same font label in parts?


As my enterprise application has items mapped to certain categories, when i want to show all the items at once it gets that mammoth count :frowning:
so by some means i need to have this fixed, as i have already given support of loading dynamic ttf font files accustomed from the server.


Well visually its not going to appear good to display 450 label at once. If you can share some screenshot then I can advice on same. In my opinion, reuse of label is advisable as we do for TableCells.


I have a scrolling list which have a custom node made of 3 label each, now on single page view i get 10 of those node and i have around 150 items so the count comes to around 450


For a scrolling list, you need to reuse the labels. If I go by your stats then at a time there should be more than 30 Labels at a time.

Do check CCTable example provided in Cocos2D-x Test App.


Is there any other way we can over come this thing?
As i have made a scroller component of my own which has certain its own limitations.


You will need to decrease the number of labels. Make your scroller reuse labels as Paras Mendiratta said. Probably there is no other way to make it work fast and stable if you have many rows of text in your scroller.


As mentioned earlier, you should reuse the label textures. 100, 200, 300 textures, all UNIQUE, will consume an incredible amount of framebuffer memory. Your test works on your windows box because your video card has a gigabyte of DDR5 RAM on it. The little mobile notebook won’t have that much memory, and the mobile tablet/phone devices will have even less.

Each label has its own unique texture, which is different than how a loaded texture works. There is no caching of label textures or automatic reuse of said label textures. Reuse them smartly because they are very expensive, especially if they are large 72 point labels.


Is there any way to use JNI rendering the Android Native TextView?
As in iOS and Windows there is no problem rendering those amount of label. So i only need a workaround rendering android native UI text component.