Android memory leak issue
I have an application with 3 tabs.
From tab #1 the user can browse to another window and I call:
Titanium.UI.currentTab.open(winx
, {
animated: true
});
If you browse back and forth the application will eventually crash due to an out of memory error:
[TRACE] E/AndroidRuntime( 787): java.lang.OutOfMemoryError: bitmap size exceeds VM budget
It seems as though the memory for a window is never freed, or some type of other memory leak.
Is this a memory leak, or is there a more appropriate way to handle windows to prevent the issue?
You can re-create this from Kitchen Sink by going to image views and going into the Animated example and hitting the 'back' button on the phone then click on the Animated example again. Repeat this about 20 times and the application will crash.
14 Answers
-
I think I have a temporary solution for the issue.
When closing every window of your app, meaning in the
win.addEventListener('close',function(e){ //here });
- Release all sounds you might have used with
sound.release();
. - Change the source of all your images to nothing (
myImage.image = ''
), and the same forbackgroundImage
. - Remove all UI elements and controls from your window (
win.remove(scrollView);
.
If you have too many, loop through them. I'm not sure if this solution completely fixes the problem, at least it seems it does in my case. I hope an official fix comes soon. This simply 'shucks'.
- Release all sounds you might have used with
-
Did anyone ever figure anything out on this (how to release the image views). I am running out of ideas. Using SDK 1.8.
-
Bump. This is still an issue in 1.7.2. and 1.8.0.
-
Hi,
I'm reproducing this issue (in 1.7.3). I tried the « solution » given by George Marmaridis above but the application freeze when I close the window if I tried to remove either an image or view.
-
Hi,
I'm reproducing this issue. I tried the « solution » above, but the application freezes if I tried to reset a Image view and/or remove a view.
Moreover the "close" event is not catched if close() is called manually (for instance to make use of the android back button), so I had to use a customClose function.
-
Did anyone find a fix for this? I cant even run my app for more than 10 secs on the device and a little longer on the emulator.
I get this error -
java.lang.OutOfMemoryError: bitmap size exceeds VM budgetI understand it could mean that the images are too big, but actually they are not.
I also got an error that there was some leak in the activity. I didnt copy the error at that time. But I will add it again later.
Anyone know a fix? Titanium team?? Aaron Saunders? You should be answer these questions and help us find a solution, so we continue using this product! Everything seems to be an issue. Please help us!
-
Using DDMS i found that Memory allocated to application is get increases as i am navigating screen by screen and after some time it crash application with force close message/Fail to load resources. Even i have remove all objects from window and after that assign null to it. i.e
window.remove(viewname);
viewname=null;
window.close();
window=null.
Please help Me OUT. -
Any help suggestion which help me out.
-
We are seeing a similar issue, but is seems to be happening on every window that we open, not just windows with image views, or table views. Basically any window that we open, then close enough times will crash the app. I open up ddms and monitor the device memory, and it slowly runs out of free space, until our android app crashes.
There just seems to be a general memory leak on all windows, in fact I don't ever notice the app releasing any memory back to the device. I really hope this will be addressed in 1.5, because it causes any app with navigation to crash if used long enough, and our app has some pretty large windows with tables views, many label, text boxes, etc.. so, our app crashes in about 15-25 open/closes of a window.
Seems like this should be a very high priority to fix.
-
I just want to bump this as it's still an issue for me - Ticket 886 that Don Thorp mentioned says it's resolved but it's clearly not. If any of the Appcelerator team are listening, please look into this - it's stopping one of my apps from being released!
-
I might be able to add another usecase, when u have a single scalable imageview (canScale is true), then open the gallery and set it to the image you picked. Then do it again several times.
I dont know what happens, but eventually you cannot change the image in the imageview, and not at all (in fact, the application doesnt enter in none of the gallery callbacks at all, nor success, nor error).
If u go to "manage applications" area and do "clear data" operation, you will be able to change the image again a couple of times, then it gets stuck again.
You can also see that in the data section of the application, the amount of data used is always the same constant thing, when u come to clear it.
-
reseting image.url and removing children doesn't seem to work. still experiencing this issue with 1.7.2
-
@michael are you running with the latest CI build?
-
Thanks! I've added Ticket 886 to track it.