when does dalvik unload shared library

1,200 views
Skip to first unread message

simon....@hotmail.com

unread,
Feb 26, 2012, 10:36:59 PM2/26/12
to android-ndk
this is really puzzle me lately moment.
I'm writing a application, and part of it use ndk. there is some
function may use native thread to download file.

I want to the download thread keep run even if the application has
called onDestroy(), but will the dalvik unload the shared library at
same time? If so, I think my application stop download task at same
time.

I look up in the android-ndk groups and find this article:
http://groups.google.com/group/android-ndk/browse_thread/thread/b1fe7ac5523249f2

where fadden says the shared library is never unloaded. but here I get
a puzzle, if the shared library is never unloaded, then if I load a
lot of shared libraries. will the system goes to a memory shortage?
how dalvik manage these shared libraries when a Activity ends its
lifecycle? Can anyone illustrate it for me?

simon....@hotmail.com

unread,
Feb 28, 2012, 4:55:46 AM2/28/12
to android-ndk


On 2月27日, 上午11时36分, "simon.zhu....@hotmail.com"
<simon.zhu....@hotmail.com> wrote:
> this is really puzzle me lately moment.
> I'm writing a application, and part of it use ndk. there is some
> function may use native thread to download file.
>
> I want to the download thread keep run even if the application has
> called onDestroy(), but will the dalvik unload the shared library at
> same time? If so, I think my application stop download task at same
> time.
>
> I look up in the android-ndk groups and find this article:http://groups.google.com/group/android-ndk/browse_thread/thread/b1fe7...
>
> where fadden says the shared library is never unloaded. but here I get
> a puzzle, if the shared library is never unloaded, then if I load a
> lot of shared libraries. will the system goes to a memory shortage?
> how dalvik manage these shared libraries when a Activity ends its
> lifecycle? Can anyone illustrate it for me?


Is there anyone can help me?

Nasif Noorudeen

unread,
Feb 28, 2012, 6:45:15 AM2/28/12
to andro...@googlegroups.com
 
Dont worry about number of shared library you are loading into the memory. You can load whatever number of library in to memory. Since library is loading in to the stack memory of ram not in heap memory of process, when they process is no longer using os will remove the libs
 
When you are agian launching application os will load the lib if it not present for the same process. I load up to 5 shared lib at same time
 
Thanks
 
Nasif

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


Tor Lillqvist

unread,
Feb 28, 2012, 11:44:28 AM2/28/12
to andro...@googlegroups.com
Dont worry about number of shared library you are loading into the memory. You can load whatever number of library in to memory.

Actually, on Android, you can't.  At least not if you use the system's dynamic linker (dlopen()): http://androidxref.com/source/xref/bionic/linker/linker.c#55

Yes, most people probably would say 128 "should be enough for anybody".

--tml

Stephen Williams

unread,
Feb 28, 2012, 12:16:20 PM2/28/12
to andro...@googlegroups.com
Could be changed in future versions of dllib, or you could include your own modified dllib (bad if compatibility changes...).

sdw


--tml


Reply all
Reply to author
Forward
0 new messages