Hi,
i have been hunting down a memory leak on android device for several days now and finally found the culprit - custom font.
The symptoms: Corona texture and lua memory indicators do not show any issues - the values are steady, but the Active Apps widget on my device is showing constantly increasing RAM usage. My game starts with ~30MB and dies at ~250MB after a minute or two.
I have a bunch of things going on in my game: explosions (sprites and emmiters), a few GLSL shaders, lighting effects with normal maps, etc.
So I was meticulously checking all stuff, switching it on and off… Nothing.
Then I switched off all HUD text messages (combo hits, points scored, warnings ) and the problem was gone. I reviewed my text handler and it is all good - I remove display object in transition onComplete(), then nil it.
Now by accident, after some refactoring, I lost the custom font assignment, so the default one was used instead - and guess what, RAM issue disappeared.
I whipped up a quick test project to prove my case. All resources are attached:
tap font to toggle between default and custom
tap remove text object onComplete to toggle well… spawned text object removal after transition completion
tap start to start text object spawn timer (500ms frequency)
tap stop to stop text object spawn timer
tap clear to trash the spawned objects
Here are results of my test:
startup - device ram usage ~40MB
MEM ~400KB
TEX ~0.1MB
default font
remove text object on transition completion: true
after 100 objects:
device ram usage 24MB
MEM ~555KB
TEX ~0.096MB
after 200 objects:
device ram usage 25.13MB
MEM ~500KB
TEX ~0.096MB
custom font
remove text object on transition completion: true
after 100 objects
device ram usage 91.15MB
MEM ~378KB
TEX ~0.085MB
after 200 objects
device ram usage 138.43MB
MEM ~440KB
TEX ~0.085MB
Devices tested on:
Samsung Galaxy Note 2 - Android 4.4.2
Kata-Tmini4 - Android 6.0
I saw a possibly relevant post on SO: Memory leaks with custom font for set custom font
My questions are:
- Can anyone confirm or disprove the issue?
- Is this only affecting android?
- Any solution available for Corona?
Many thanks for any insights in advance.
P.S.: I am unable to attache the apl due to size restriction, here is an external link: https://nofile.io/f/nFvrxZ6Ohkn/text_ram_issue_apk_live_sync.zip