On 07/08/2011 07:48 AM, Jeremy Friesner wrote:
> This all works well, but there is one minor issue where I'd like to
> improve things: after running for a while, the allocation and
> deallocation of 128kB buffers, interspersed with smaller
> allocations/deallocations, causes fragmentation in the process's
> heap, with the end result that the process appears to be using a lot
> more memory than it actually has allocated. This doesn't cause real
> problems (AFAICT), but because the GUI for the system has a RAM Usage
> Indicator (that gets its info from /proc/meminfo, and displays total
> memory-usage as a percentage of physical RAM), users are prone to
> wonder why so much RAM is being used even when the program is idle.
> The heap fragmentation makes it look like there is a memory leak,
> even when there technically isn't.
The size allocated by a process is more accurately measured with
/proc/self/maps or /proc/self/smaps than with /proc/meminfo. For the
128k buffers, you can mmap/munmap anonymous memory, this way, you will
only consume what you use. Malloc also has a threshold above which it
uses mmap, maybe you can change that threshold to be 128KiB (I think it
is 4MiB by default). See mallopt documentation.
--
Gilles.
_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help