For the past few months I have been having a issue with apps I have created for android. It appears that after a relatively low time of being open (roughly 10-20 minutes), my phone starts to get extremely hot. On top of that, the app will occasionally start lagging a ton (dropping roughly 30-40 frames). Ive been trying to track down the issue for a while but have had no luck. I have a few ideas as to what could be causing the problem but have not been able to confirm.
Heres a bit of information about my setup that may be the cause of the issue:
The app uses roughly 50-80MB, if sounds or high quality images are loaded sometimes can go as high as 140MB.
Everything is directly drawn onto Javas canvas. (Is it alright to try to produce a high quality app by using Javas canvas to draw?)
I am not using androids "activity" system. Instead I have my own system which creates and removes objects through passing strings when certain events are triggered. (So technically the entire program is run in the main activity at all time, and the objects are handled through my system).
I am not using any of androids UI elements, instead I have created everything on my own. There is nothing super complicated about them, I am just not sure if using androids UI elements has any benefits that im unaware of.
The main object update function is run in a thread, while the paint method calls invalidate on its own. My objects are updated through the following code
while (roomRunning) { if (!isPaused) update(); try { synchronized (this) { wait(5); } } catch (InterruptedException e) { e.printStackTrace(); } }
.005 seconds is the code update rate. This update rate is very close to 60 frames, and feels very smooth, however I am still concerned it may be to fast (especially since the app occasionally may have to process hundreds of objects per code update.
I have monitored the memory usage of my app and compared it to other games running on my phone. The memory usage appears to be up there with many other apps, however those do not cause a overheat. Also, when running my app on my friends phone I have not noticed any overheating or lag issues.
Could this issue be caused by a faulty phone, or is there something serious I need to fix in my app?
If there is any more information which is needed to solve this problem, please let me know.