Android :: ClassLoader Leaking Memory?
Dec 17, 2009
I have a ClassLoader in Activity's onCreate which loads a specific class from a library, and is working fine, except that when activity is destroyed, the memory resources about the loaded class are not released.If the same activity gets created multiple times very quickly (by launching it, and destroying it by pressing the Back button), and the process doesn't happen to be killed by Android yet, the memory usage of the corresponding process grows continuously until the app crashes,and process dies.The problem is that this happens even if no objects are instantiated using the loaded class. There seems a problem with garbage collector, which doesn't seem to release resources about the loaded class on Destroy even if there are no references to it.If android would have killed the process right away when the last activity of the process gets finished, there wouldn't be a problem, but this is managed by Android system, and it doesn't always kill the process right away. A workaround may be to kill the process explicitly on destroy, but this is not encouraged way to do, as Android is supposed to manage the process.
An alternative is to have a functionality that allows a class to be unloaded onDestroy, but this doesn't exist. By design, the garbage collector is supposed to take care of this.Is there a solution regarding this?
View 8 Replies
Dec 16, 2009
I'm trying to locate a memory leak in my app (it's client for a mediacenter). So I start it up, go to the screen that lists all movies, go back to my home activity, trigger the GC a few times manually via DDMS, dump the memory heap, pull it, convert it and load it into MIT in Eclipse.
Now the movie list screen is pretty heavy, around 800k of movie objects, which should be freed when I go back to the home screen. However, it stays allocated, with the GC root as a local variable in the main thread at ActivityThread.ContextCleanupInfo (see attached screenshot).
I've tried searching but there is no documentation on this class, not even in the source code. Is there any way to avoid this kind of behavior? Am I doing something wrong or is the problem in Android? My app is open source and can be checked out here[1]. http://code.google.com/p/android-xbmcremote/
View 4 Replies
View Related
Mar 31, 2009
What would be the best way to debug a leaking program?
I have developed a media player (includes a background service doing the playing, and a UI, and I access getResources(), MediaStore and things like this often).
Whenever I rotate the screen or reenter the app the total memory allocated to my process grows some 70 to 100KB. After some 6-10 rotations it is dead due to an out of memory exception.
In the meantime I have removed every static modifier to global vars, added an onDestroy function that unregisters the intents and service connection (and even puts every global var to null again :P), but still the program memory grows... and dies after a few rotations.
Given the situation I even made the program stop right after just calling setContentView, and still the memory leaks:
CODE:......................
View 3 Replies
View Related
Aug 7, 2009
http://developer.android.com/reference/android/app/Activity.html
The Activity Lifecycle could have implementation and or design bug: One case is to initialize a big image in onCreate(), try to reuse the image during the whole lifecycle, and then recycle the image in onDestroy(). Test showed that onCreate() is called every time one navigate away from the activity and back again, but onDestroy() is not called at all. This behavour causes memory leaking for the big image (size 960*1920). After 6+ times away and back to activity, the system runs out of memory and has to kill the process.
One workaround is to initialize the big image in onResume() and recycle in onPause(), but that's not so good reuse.
Could it be better to change the process (as shown in the diagram) a little bit such as: Call onDestroy() first when a process is killed?
View 3 Replies
View Related
Nov 18, 2010
I created a simple app with a ListView following the ListActivity examples I found on the net.
The app has 2 activities with the first having a button to create the second. When i hit the close button on the second activity I would like it to release its memory (or at least allow it to be garbage collected).
Currently it will never release.
I must be doing something wrong here because the MyListActivity never gets released. Can anyone tell me if I am doing something wrong with the way my activities are created/destroyed? or if my usage of the ListView is wrong?
My App as a zip - http://www.mediafire.com/?l26o5hz2bmbwk6j
Screen Shot of Eclipse MAT showing the list activity never releasing memory - www.mediafire.com/?qr6ga0k
View 1 Replies
View Related
Oct 23, 2009
can anyone tell me any solution or tool provided by Android to find the exact place of memory leaking?
View 2 Replies
View Related
May 7, 2010
I'm writing an app that has a foreground service, content provider, and a Activity front end that binds to the service and gets back a List of objects using AIDL. The service does work and updates a database.
If I leave the activity open for 4-8+ hours, and go to the "Running Services" section under settings on the phone (Nexus One) an unusually large amount of memory being used is shown (~42MB).
I figure there is a leak. When I check the heap memory i get Heap size:~18MB, ~2MB allocated, ~16MB free. Analyzing the hprof in Eclipse MAT seems fine, which leads me to theorize that memory is leaking on the stack. Is this even possible? If it is, what can I do to stop or investigate the leak? Is the reported memory usage on the "Running Services" section of android even correct (I assume it is)?
Another note: I have been unable to reproduce this issue when the UI is not up (with only the service running)
View 1 Replies
View Related
Jan 10, 2010
I'm still in the concept stage so I don't need implementation details. My question is whether it is possible is transfer a JAR file over a socket and use a classloader to launch an activity.
View 5 Replies
View Related
Jun 25, 2010
I newed a DexClassLoader to load one jar file dynamicly.I think I have to set my cl to be default ClassLoader of Activity.to achieve similar thing. However, it does not work. So event I changed Thread's context classloader, Activity's classloader is not my cl.My question is how to change Activity's ClassLoader?
View 5 Replies
View Related
Mar 31, 2009
I definitely have a memory leak problem and i'm trying to figure out there. After 6-10 config changes i'm getting out of memory in regards to BitmapFactory. I'm kind of suspect that this is going on within adapter. I have a listview . ListItems are an thumbnail image ( ImageView ) and TextView for text.
Here is the getView code.
CODE:..................
And get ThumbnailBitmap() is basically BitmapFactory.decodeByteArray ..
Is it possible that i'm leaking drawables ? Heap is not increasing by the way .
View 3 Replies
View Related
Sep 28, 2010
I read the Avoiding Memory Leaks article with interest, and am concerned about danging references to the context object. I have a class like the following.
CODE:.........
Is it a problem to have a reference to a LayoutInflater object, since it must be using the context object somehow? Is there a better design pattern for what I'm trying to do here? (Use the context only to initially inflate the XML; from then on just use the View that's passed in to getView)
View 1 Replies
View Related
May 9, 2010
I read some documentations about classloaders, but im still not sure where and why they are needed. The Android API says: Loads classes and resources from a repository. One or more class loaders are installed at runtime. These are consulted whenever the runtime system needs a specific class that is not yet available in-memory.So if i understand this correct, there can be many classlaoders which are responsible for loading new classes. But how the system decides which to use? And in which situation should a developer instantiate a new classloader? In the Android API for Intent there is a method
If activity A which is located in Project A (in Eclipse) defines an object which i want to send to Activity B in Project B using putExtra of the Intent object. If this object which is send over the Intent is not defined (source code in project B), then there is a NoClassDefFoundException. So can i use the method setExtraClassloader to avoid this exception? If yes, how can i decide which classloader object i have to pass? And how do I instantiate it correctly?
View 2 Replies
View Related
May 5, 2010
Anybody else thinking that the revs are being leaked deliberatly and they are using us to test them and find the bugs?
View 22 Replies
View Related
Jul 7, 2010
I finally decided to do it. I had an idea to use the corner of a sheet of paper dabbed in krazy glue to slide up and down the sides and bottom of my phone while holding the screen down for a while. Surprised, it worked like a champ, and any excess glue that got anywhere on the phone was easily removed with acetone. Unless you have very sturdy hands, I would not advise this.
View 5 Replies
View Related
Nov 19, 2009
The bottom four buttons on my droid leak light if I look at it certain angle...
View 5 Replies
View Related
Nov 13, 2009
I just picked up a Droid today, and I just seen, above the 4 touch buttons when they are lit up, if you tilt the phone down you can see light leaking up to the edge of the screen. Does anyone else have this problem or should I return my device?
View 36 Replies
View Related
Dec 2, 2009
How to tell the installer intent to install on memory card or on phone memory ?
View 2 Replies
View Related
Jan 21, 2010
My application is designed to support both portrait and landscape orientations. Using my HTC IO device, it survives 12 orientation changes before throwing an out of memory exception while inflating my activity.When I follow the recommended procedure of using DDMS to first force a GC and then write a heap dump, and then load it into the Eclipse Memory Analyzer, there is only one retained instance of my application, as there should be. None of the other retained objects are obvious offenders. Just for yuks, I reran the test, and did everything the same way except I didn't force a GC. In this case I see 13 instances of my application, which is more consistent with throwing an OOM exception. Is this telling me something useful? If forcing a GC with DDMS reclaims the memory used by now-defunct instances of my activity, I would have thought the VM would have garbage collected some, if not all of these defunct activities automatically. Do I need to request GC at the very beginning of my activity lifecycle to make sure?
View 7 Replies
View Related
Jul 10, 2010
iv got a x10i how do i transfer photos from phone memory to my memory card as i can't find an option do do this.
View 1 Replies
View Related
Jun 24, 2010
My phone is low on memory, when I open my app manager it shows my mail app is using 59mb of memory. I have erased all mail and cleared the cache with no change. I am running android 2.1
View 3 Replies
View Related
Jun 25, 2010
I have a 4GB SD card and it thinks that it has a total of 200MB on there (Its empty). I have tried formatting it using my Mac & via the phone itself but it continues to believe that its a 200MB MiniSD card.
View 1 Replies
View Related
Sep 18, 2010
Is there anyway I can install apps onto the memory card rather then the phones memory as I keep getting the 'memory low' message on my phone esp when I install games/apps that are around 15mb in size.
View 1 Replies
View Related
Sep 9, 2010
Not had my desire long but down loaded a few apps for it they all seem to be stored on phone memory not the sd card. what is stored to the sd card seems to be unused so far. do you have to set it up to use sd card or does it know one is fitted. does it switch to sd card when phone memory full. will run out of space soon if can't get things to store to card instead of phone mem.
View 5 Replies
View Related
Aug 19, 2010
Every time I download a app it installs in phone memory and not internal memory.Where is the settings for this? I am switching over from windows mobile phone to my new incredible
View 1 Replies
View Related
Sep 16, 2010
I need help to get my apps to the memory card instead of phone memory, how do I do that?
View 2 Replies
View Related
Apr 7, 2013
I'm wanting to learn more about android. Is there a way to use memory from the sd card for the phones internal memory? Is there an app that will tell me whats useing up so much memory? I'm on the ZTE warp sequent ,rooted.
View 1 Replies
View Related
Jun 24, 2010
I need to check my application for memory leaks, i also need to see the memory allocation of my application.I downloaded and installed eclipse memory analyzer, and it looks like the first step is to open a heap dump.But what is a heap dump, how can i create a heap dump.And how exactly am i going to use this software, I did some googling but i couldn't find any useful information
View 3 Replies
View Related
Apr 27, 2010
how can you tell where an app is being downloaded to? is everything set to download to the sd card?if not what is set to download to the phone memory? i'm guessing phone back ups and settings?
View 3 Replies
View Related
Jun 7, 2010
Here's the proof of the madness. I deleted several space hogging applications and it hasn't gone away. I have also power cycled and messed around with a few settings and the low storage warning will not go away.
View 49 Replies
View Related
Sep 22, 2010
I used advance task killer and check frequently to see which programs are running in the background, frequently there are a number of programs I never use running in the background. How do I keep these programs from loading?
View 5 Replies
View Related