Thanks for the response.

I have already run it using hprof and mat, and located the issue, and
the problem lies in here:
onCreate(..) {
...
PathClassLoader classLoader =  new PathClassLoader("/path/to/apk.apk",
getClassLoader());
classLoader.loadClass("path.to.class");
classLoader = null;
}


Only these three lines will cause a "leak" if you keep on creating
this activity and destroying it with the back button.
The class is getting loaded successfully, but the resources are never
released. As you can see, I set the reference of the classLoader to
null, and I never instantiate any object using the loaded class, but
the problem still persists.

I have isolated the code as above, and you can clearly see that the
memory is growing.

Can the getClassLoader() reference create a problem here?

Thanks

B.


On Dec 17, 2:57 pm, fadden <[email protected]> wrote:
> On Dec 17, 7:45 am, "B++" <[email protected]> wrote:
>
> > 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.
>
> It usually turns out that something is holding a reference to whatever
> it is that isn't getting thrown away.  The best way to figure this out
> is to get the HPROF output and run it through jhat or MAT.
>
> See also:
>  http://android-developers.blogspot.com/2009/01/avoiding-memory-leaks....
>  http://android.git.kernel.org/?p=platform/dalvik.git;a=blob_plain;f=d...
>  http://kohlerm.blogspot.com/

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to