This is the mail archive of the
mailing list for the glibc project.
Re: Amount of virtual Memory larger than heap peak
- From: "Ryan Arnold" <ryan dot arnold at gmail dot com>
- To: "Johannes Singler" <singler at ira dot uka dot de>
- Cc: libc-help at sourceware dot org
- Date: Thu, 9 Oct 2008 12:04:17 -0500
- Subject: Re: Amount of virtual Memory larger than heap peak
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=ysSdG+6y3rzfp21iw71GbugXvifUl3zGblU7IHbilaU=; b=FkFAlNqvmolDBp93ZZ58NGKqmMhebR+GV/R1w5bsSqprAPzRBcaJTRzKcztt3mO5lC EKhMgVSW/LUwl0LuBZRlqaES44Mqfo4X7+A+VPpYmvXrkcNWzKwrW2Ry6k1OwTWrXIAK BFHOdCKwfwHO4FT+TlAWgWJPYJa+1IrH3O+9k=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=gQKFILmdBVSYOhp65KaqIrrRwLhXOFl8dgGv56Na7b1hFGn4uMJpgXXwS9xpCMOvxZ z2GjofH+No4ubincgVKVTmEwravm6hYc30X6VLeSmKN5mFwvpfxQoKRep+rTC9nFYtQu ShLbhFv5TQdPjR5mWltwuzNg4k9W+Er5BmfPE=
- References: <48EE16F3.email@example.com>
On Thu, Oct 9, 2008 at 9:36 AM, Johannes Singler <firstname.lastname@example.org> wrote:
> My program allocates and deallocates large chunks (Megabytes) of memory
> many times (using new, but this should be mapped to malloc). For
> example, using memusage.sh, 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