On Sat, Aug 07, 2010 at 08:19:47PM +0800, Edwin Eyan Moragas wrote:
> Hi misc,
>
> assuming that a long running app would malloc(3) when needed and then
> free(3)s the resource immediately when it is done, is memory
> fragmentation still a concern for long running apps?
>
> what are steps that you take to manage this problem if ever it is a problem?
>
> best,
>
> /e
Scenarios do exists where a leak-free process still can run out of
mem, i.e. if it does a lot of small allocations, these are scattered
through its address space. Big allocations following that could fail,
even if the available memory is bigger than the size requested.
Otoh, if the sum of your allocations stays below the malloc cache
size, malloc will never do any mmap(2) calls after the initial ones and
fragmentation will not be any issue.
The only answer is: it depends, but in general it is not a problem,
this is especially true for 64-bit systems.
-Otto