Mail Archives: djgpp/1997/03/14/11:05:16
(Please also reply personally to a DOT appleyard AT fs2 DOT mt DOT umist DOT ac DOT uk)
In the file djgpp\src\libc\ansi\stdlib\malloc.c, on working manually through
the source forms of malloc() and its helper morecore():-
(0) Here, OV = sizeof(union overhead).
(1) The first call of malloc() has 11 lines of text which carefully align
the sbrk() at OV bytes less than a page boundary. This is clearly so that as
few page boundaries as possible occur inside allocated store blocks; but what
harm befalls if allocated blocks straddle page boundaries?
(2) If I ask for a block of size N, if N+OV > pagesize, having rounded N up
to P (where P = the next (OV bytes less than a multiple of pagesize)),
morecore() asks for not (P/pagesize) pages but (P/pagesize+1) pages!!! Why the
unused extra page each time??? If many of the malloc() requests are from 2 to
a few pages each, a lot of memory is going to be wasted in these unused pages.
- Raw text -