mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Yuxin Ren <ryx@gwmail.gwu.edu>
To: musl@lists.openwall.com
Subject: confusion about brk and mmap in expand_heap in malloc implementation
Date: Thu, 10 Sep 2015 14:58:33 -0400	[thread overview]
Message-ID: <CAAKbDrfwRxP_yQLapYdhQR1ubDhnZBo0ebCQk7e02L8A0HHDHw@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 426 bytes --]

Hi,

I found in the __expand_heap function used by malloc, if brk fails, it will
use mmap to get a memory area.
I think in this case, this area should be returned back to system via
munmap.
But in my test, when I free such area, I found it is still passed to
madvise, not munmap.

How do we track if an area is expanded by brk or mmap?
And when we free an area, how do we decide to use munmap or madvise?

Thanks a lot.
Yuxin

[-- Attachment #2: Type: text/html, Size: 1584 bytes --]

             reply	other threads:[~2015-09-10 18:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-10 18:58 Yuxin Ren [this message]
2015-09-10 20:58 ` Rich Felker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAAKbDrfwRxP_yQLapYdhQR1ubDhnZBo0ebCQk7e02L8A0HHDHw@mail.gmail.com \
    --to=ryx@gwmail.gwu.edu \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).