This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Amount of virtual Memory larger than heap peak

On Thu, Oct 9, 2008 at 9:36 AM, Johannes Singler <> wrote:
> Hi!
> My program allocates and deallocates large chunks (Megabytes) of memory
> many times (using new[], but this should be mapped to malloc).  For
> example, using, I find out that the heap peak is about
> 100MB.  However, the virtual memory size of my program has grown to
> about twice this size, as shown by top.  The resident set size stays at
> about 100MB, as expected.

You'll have to see what morecore does when freeing memory but I've
been told that when malloc wants to create a new malloc arena that it
moves sbrk.  Free can't move sbrk back down because another malloc
call may be using the arena.

> I don't use mmap, but read and write large amounts of data from disk
> using read(int fd, void *buf, size_t count) and the corresponding write.

You should probably use mmap to allocate and use mallopt to force mmap
usage.  Therefore you can reclaim memory when you're done with it.

Ryan S. Arnold

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]