[uClinux-dev] Reclaiming Memory

Harry Gunnarsson mrharryg at gmail.com
Thu Nov 1 16:38:25 EST 2007


Hi,
I am using 2.6.22.6 on top of 20070130 distro on a Coldfire 5272 system.
Standard SLAB configured.

I observe a memory allocation behavior which I am not entirely fond of, and
I wonder if any of you wise gentlemen could shed some light on this issue.

Firstly, I have an app which has a high peak memory usage; it is downloading
a 7-zip compressed archiveinto memory and subsequently uncompress the the
archive members. Therefore the peak usage is one buffer holding the archive
and one for the uncompressed data. Lets for simplicity's sake say that the
archive is 2.5 M and the largest member in the archive is about the same.
Due to the power-of-two allocation scheme one would need 2x4M, which is fine
on my system.

Since this code piece is simple user-level linux code, i am able to run
everything on my Ubuntu system for the purpose of memory profiling etc. I
run it under 'valgrind' memory checker and it reports absolutely no leaks.

So here's the problem, if I run this download-uncompress routine
back-to-back, it always works fine the first time, but it could bail on the
second/third/fourth time due to allocation failure on one of the big buffers
I need. I never figured out why this is and I haven't figured out how to
circumvent this. Since I have returned the buffers with free(), the system
should be able to hand them out again in the next malloc() call, right?

How can I make the system reclaim the memory immediately, so it is readily
available for the next big malloc()?

Thanks in advance,
Harry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.uclinux.org/pipermail/uclinux-dev/attachments/20071101/27dace4a/attachment.html


More information about the uClinux-dev mailing list