www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/07/17/11:51:22

Date: Thu, 17 Jul 1997 08:48:07 -0700 (PDT)
Message-Id: <199707171548.IAA02022@adit.ap.net>
Mime-Version: 1.0
To: rs AT redplanet DOT com DOT cy
From: Nate Eldredge <eldredge AT ap DOT net>
Subject: Re: mem alloc taking up power of 2
Cc: djgpp AT delorie DOT com

>When I malloc a structure that takes up say 34k, djgpp or dpmi takes
>64k, a loss of 20k.
>So if I allocate 32 structures, I lose 640k.
AFAIK, no you don't. malloc uses sbrk to get memory from the DPMI server. It
gets *that* memory in powers of 2 to reduce overhead, but then parcels it
out to malloc calls as it's needed. So each structure should just be using a
34K block, it's just that malloc grabbed some extra which will be given to
the next request.

What makes you think you are losing memory?

Nate Eldredge
eldredge AT ap DOT net



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019