Re: Understanding Linux addr space, malloc, and heap

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Oct 21, 2005 at 12:10:47PM -0400, Vincent W. Freeh wrote:
> First, thanks for all the help and attention.  I am learning much.
> 
> I think the focus of this discussion should be on mprotect.  I 
> understand that spec says it only works on mmap'd memory.  So does 
> malloc use mmap?  If not why does it work at all?

_Sometimes_ malloc() uses mmap, and _sometimes_ it doesn't (it will
use memory by adjust the brk pointer).  This can be adjusted via
various tuning parameters to malloc.  I suggest you read the info
documentation for glibc's malloc() and mallopt() calls.  (Note that
mallopt parameters are non-portable, and may not apply if you are
using another OS, another version of glibc, or if you have replaced
the malloc with another implementation --- as some application writers
might do.)

Bottom line is you must not count on the type of memory returned by
malloc().  It is given the freedom in the specifications to use
whatever free memory it deems most likely to provide better
application performance.  An application which is willing to be
malloc() specific can use various interfaces to tune various
malloc()'s behavior for performance reasons.

						- Ted
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux