Re: Heap allocation

From: SM Ryan (wyrmwif_at_tango-sierra-oscar-foxtrot-tango.fake.org)
Date: 09/01/04


Date: Wed, 01 Sep 2004 19:06:18 -0000

arut@post.com (asm) wrote:
# Hi All,
#
# When a process allocates dynamic storage by making a call
# to malloc(), does it get allocated from a per process heap
# or a system wide heap?

Per process. Unless you do something like shmat or mmap, all your
writable memory belongs to your process alone. And when you fork,
the child process get its own copy of the heap, so the heaps of
parent and child are separate and still only belongs to the one
process.

System V shared memory and memory mapped files do allow different
processes to share memory, but your process must make system calls
to set up such regions--they won't happen behind your back.

(Read and execute only code loaded from the executable may be
handled with something similar to mmap; but since nobody can write
these pages, it is irrelevant whether they are shared or not.)

--
SM Ryan http://www.rawbw.com/~wyrmwif/
Death is the worry of the living. The dead, like myself,
only worry about decay and necrophiliacs.


Relevant Pages

  • Re: Lcc-win32 extensions to C
    ... compiled with a C++ compiler or a C compiler. ... Yes, but if you do not use GC, you allocate more memory than needed to ... Using a non-GC'ed heap+ a GC'ed heap requires also more memory... ... Collector, since GC technologies are much more advanced than simple ...
    (comp.std.c)
  • Re: Huge pages and small pages. . .
    ... you need to have them cached in the TLB; if the TLB runs out of ... >>> low end of the heap, until someone figures out a way to tell the system ... >> causing them to be COW'd to real memory. ... I believe the swapper will kill them fast once you have ...
    (Linux-Kernel)
  • Re: Help wanted - problems with heap
    ... Memory pressure, because of limited heap size. ... identified that by failures to allocate memory. ... Any pointers as to work out what is happening would be welcome. ...
    (rec.games.roguelike.development)
  • Re: ASP.NET WP memory consumption problem & debugging on AppDomain bas
    ... Downloading Large Files Causes a Large Memory Loss and Causes the ... > Bytes in Loader Heap 46673920.000 ... > Promoted Finalization-Memory from Gen 1 0.000 ... > Working Set 648499200.000 ...
    (microsoft.public.dotnet.framework.aspnet)
  • Garbage Collection/OutOfMemory Exception 2
    ... The Garbage collector is designed and optimised for Client based ... less memory fragmentation and allow intensive programs to run. ... This version locked up at less than 500meg of memory usage. ... It has gen 0,1,2 collections, heap size, induced gc etc etc. ...
    (microsoft.public.dotnet.framework.clr)