Microsoft C Problem

Stuart R. Kemp kemp at umn-cs.CS.UMN.EDU
Sat Nov 11 05:45:17 AEST 1989


I have the the following problem using MSC 5.1:
(Yes, I have read the manual in an attempt to solve it!)

The problem is with malloc() and free(), using
large memory module.

Following is a contrived example to illustrate:

malloc() a large area, then free() it,
then malloc() a smaller area, and free() it,
then malloc() the large area again. 
The second time the large area is malloc()ed,
it will not be the same as the first area.
By carefully contriving an example, it would
be possible to have malloc() calls fail
when there *IS* enough memory available.

MSC gets blocks of memory from DOS, and controls
them internally, but it appears that it does
not do any merging of adjacent areas, nor
any intelligent selection of available areas.
The first large malloced area above is still available,
but only as a small area, and a larger area.
(Thus failure of malloc()'s mentioned above.)

In DOS, is is possible to control the allocation
strategy - I need something similar for MSC, or
a way to force MSC to release internal malloc()
areas back to DOS, and let DOS do any merging
of adjacent areas.

Is there something in the manual that I have missed?

Replies via email, please.

-Stuart Kemp
kemp at umn-cs.cs.umn.edu



More information about the Comp.lang.c mailing list