Mail Archives: djgpp/1994/08/24/00:43:22
I think I understand what is going on, but I am cc'ing this to the djgpp list
for general comment.
Problem summary:
A test program malloc's several equal sized hunks of memory. The free
memory available drops when the program runs, but by less than the amount of
memory allocated. Behavior is somewhat different under xms and dpmi, but
both seem to fail.
Suggested explanation:
When memory is malloc'ed, an entry is made in a descriptor table, but
physical memory isn't actually allocated until you generate a page fault by
referencing the memory. Malloc puts some info at the beginning of a block,
so some of the memory is touched immediately, and small blocks seem to work
while large ones fail. Evidence for this conjecture is that if the test
program uses calloc (which zeroes allocated memory) rather than malloc, the
reported physical memory available does decrease by more than the amount
allocated.
Comments anyone?
- Raw text -