good chemistry is complicated,
and a little bit messy -LW
OS memory reclamation with threads on linuxby zentara (Archbishop)
|on Aug 27, 2008 at 16:28 UTC||Need Help??|
On 1 of the newsgroups, someone asked about the pros/cons differences between using forks or threads. Well the newsgroup is c oriented, and I thought I would mention the way that interpreted languages (like Perl) will hold onto memory released by threads. Specifically I mentioned that if a high memory usage thread is run first, then a series of low memory usage threads, the memory of the process will stay at the high memory usage. I used the following script to demonstrate. (I have a 1 gig ram on a linux 2.6.22 kernel). The results were unpredictable, but generally followed the rule that heavy mem use is freed, medium use is half freed, and light use ( <5%) is not freed( but may be on occaision).
So it seems that the kernel is deciding how much to free, depending on some internal formula.
The question is: Can we trust top/ps to really report what is going on. Since most threaded scripts may go 10% up occaisionally, if they don't reach the kernel threshold for freeing, is that dead memory, or will the kernel auto-free more (the diff between 5% and .3%) if it needs the memory for other apps.
This would be great news for threaded apps, but I worry about not being able to trust top/ps, or the kernel doing things behind the scenes.
Anyways, this may be a mechanism to reclaim memory in Perl. I would appreciate any thoughts, comments on what is happening.
I'm not really a human, but I play one on earth Remember How Lucky You Are