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?

Thanks,

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

Reply via email to