Android Question Increasing ram usage in every customlistview activity create

Mousa Najafi

Licensed User
I've used customlistview class to design a google's voice search like app.The listview has 10 panels that each one includes small image (20 kB or less) and 2 labels and a button. It works smoothly at first but ram usage increasing after every
activty create or pause which fired by device rotation or back button pressing and finally leads to app crash.
I searched forums and tried most solutions like as following:
- declaring bitmap variblas in process globals and loading by bitmaploadsample just one time by usinf firsttime in activity create
- clearing listview in activty pause
Project files are attached , I couldn't includes whole project files and just source code and images included due to file size more than 512 KB
Actually customlistview was the best solution to design voice search like user interface but this bug puzzled me.
Please help me to overcome this issue

Mousa Najafi

Licensed User
thanks for your fast reply.
I've tested in release mode on the galaxy S4 mini and galaxy S5 . In Both devices ram increasing after orientation changes and sometimes take longer time to crash and sometimes crashes easily also it crashed just on S5
Actually I am not intending to swith another customlistview libraries for this app because your customlistview class was easy to implement my UI.
Is B4A v4 available to download?


Staff member
Licensed User
V4 beta version was released. However the memory related changes only affect the rapid debugger.

Your code can be optimized.
You do need to load the font each time that the activity is created. Load it once and store it in a process global variable.

Instead of drawing the line on each panel you should draw it once (when FirstTime is true) on a mutable bitmap and then add the bitmap to the panels (with ImageView).

Mousa Najafi

Licensed User
Thank you so much for your kind help Mr. Erel
Doing your suggestion decreased the ram usage too much(from 50 meg to 6 at start) and solved crash problem. still I will optimize more by
declaring images bitmap as process global variable since there is a small ram increasing after every screen rotation