Bug? Activity Memory Leak?

Jack Cole

Active Member
Licensed User
I am having trouble with memory leaks. I have one app with millions of installs. There are thousands of out of memory errors daily tracked on Google Analytics. Many of these, I was able to reduce. However, there are still significant problems.

In investigating the issue, there is a loss of 2 to 3K of free memory when orientation changes or a new activity is loaded and then closed.

I have attached a simple example. Switching orientation over and over eventually leads to a forced close with an out of memory error.

The attached example needs the VBBitmap library.

Is this an Android problem or something that could be improved in the generated java code?

Best regards,
Jack
 

Attachments

Jack Cole

Active Member
Licensed User
Thanks Erel. It seems to be related to the layout animations. Disabling that seems to take care of the leak on my test devices. I do like the animation. Any ideas on how to be able to use those without it causing a problem?
 

Jack Cole

Active Member
Licensed User
Droid Razr HD with 4.4.2. It also occurs on Kindle Fire HD.

Here is an example with the app example running on the Fire HD. In the log below, you see what happens when I change orientation.

** Activity (main) Pause, UserClosed = false **
PackageAdded: package:b4a.example
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
free mem 47122.9609375
free heap mem 63348272
** Activity (main) Pause, UserClosed = false **
** Activity (main) Create, isFirst = false **
** Activity (main) Resume **
free mem 43632.1484375
free heap mem 62448264
** Activity (main) Pause, UserClosed = false **
** Activity (main) Create, isFirst = false **
** Activity (main) Resume **
free mem 40942.125
free heap mem 62355640
** Activity (main) Pause, UserClosed = false **
** Activity (main) Create, isFirst = false **
** Activity (main) Resume **
free mem 38293.921875
free heap mem 62309024
** Activity (main) Pause, UserClosed = false **
** Activity (main) Create, isFirst = false **
** Activity (main) Resume **
free mem 35645.859375
free heap mem 62263344
** Activity (main) Pause, UserClosed = false **
** Activity (main) Create, isFirst = false **
** Activity (main) Resume **
free mem 32998.8046875
free heap mem 62209912
** Activity (main) Pause, UserClosed = false **
** Activity (main) Create, isFirst = false **
** Activity (main) Resume **
free mem 30343.4140625
free heap mem 62164408
Here is what it does with the animation turned off on the layout. Does not have the leak.

** Activity (main) Pause, UserClosed = false **
PackageAdded: package:b4a.example
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
free mem 47130.2265625
free heap mem 63348360
** Activity (main) Pause, UserClosed = false **
** Activity (main) Create, isFirst = false **
** Activity (main) Resume **
free mem 46289.8671875
free heap mem 62494344
** Activity (main) Pause, UserClosed = false **
** Activity (main) Create, isFirst = false **
** Activity (main) Resume **
free mem 46251.8359375
free heap mem 62454480
** Activity (main) Pause, UserClosed = false **
** Activity (main) Create, isFirst = false **
** Activity (main) Resume **
free mem 46247.0234375
free heap mem 62450600
** Activity (main) Pause, UserClosed = false **
** Activity (main) Create, isFirst = false **
** Activity (main) Resume **
free mem 46209.65625
free heap mem 62411456
** Activity (main) Pause, UserClosed = false **
** Activity (main) Create, isFirst = false **
** Activity (main) Resume **
free mem 46206.3671875
free heap mem 62408888
** Activity (main) Pause, UserClosed = false **
** Activity (main) Create, isFirst = false **
** Activity (main) Resume **
free mem 46208.546875
free heap mem 62410608
 
Top