I want my Memory back ;-)

"Jérôme M. Berger" jeberger at free.fr
Wed Jul 14 01:29:03 PDT 2010


ABothe wrote:
> So there isn't any other method than calling C's free(); or malloc
> (); ?
	Note that there is no guarantee that C's malloc/free will return
the memory to the OS either (*). The only way to be sure that the
memory will be returned is to call mmap/munmap (or their equivalent
on whatever OS you're using).

(*) Most malloc implementations allocate large chunks of memory
using mmap, which can return the memory to the OS, but they allocate
small chunks with sbrk, which can't. As proof, see the attached C
code which prints:

At the beginning:
VmSize:	    3872 kB
After allocating the memory:
VmSize:	   36608 kB
After releasing the memory:
VmSize:	   36608 kB


		Jerome
-- 
mailto:jeberger at free.fr
http://jeberger.free.fr
Jabber: jeberger at jabber.fr
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.c
Type: text/x-csrc
Size: 1305 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20100714/bee83b71/attachment-0001.c>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: OpenPGP digital signature
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20100714/bee83b71/attachment-0001.pgp>


More information about the Digitalmars-d mailing list