🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #3791

Need way to monitor actual memory on DOS heap

#3791
From: John Antypas
Date: Wed, 14 Oct 1992 23:01
34 lines
1697 bytes
Here's one for the DOS veterans...

In my Microsoft C (or Borland) program, I allocate memory via malloc et al.
in small model.  The set of statements proceeds roughly as follows:

ptr1 = malloc(SIZEA);
...
ptr2 = malloc(SIZEB);
...
ptr3 = malloc(SIZEC);
...
if (_memavl() < MIN_SIZE) { error code here }
...
free(ptr2);
...
if (_memavl() < MIN_SIZE) { error code here }
...

What SHOULD happen is DOS should report that SIZEA+SIZEC bytes of 
memory are no longer available.  Instead it reports SIZEA+SIZEB+SIZEC
are used (or rather that top-SIZEA-SIZEB-SIZEC are available).
This may be correct for a heap, but it causes trouble for me.  
I can't be sure the heap will 'unwind' in the order wound.

Is there any way to find the actual amount of memory available for
allocation at any moment that takes into account the memory just
allocated or freed?  By the way, I'm not wed to using malloc/free,
if anything else works, let me know?
-- 
John Antypas / Senior Software Engineer	johna@mobdig.com
MobileDigital Corp -- Wireless Network Wizards 
Remember, the shortest distance between two points is a straight line, but it
gets even shorter when you don't have to string a line between those two
points.
Technical Details
Message-ID: <1992Oct14.230131.16615@mobdig.ncal.mobdig.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!charon.amdahl.com!pacbell.com!ames!kronos.arc.nasa.gov!iscnvx!netcomsv!mobdig!johna

Show Full Headers
Complete Article Headers
Newsgroups: comp.os.msdos.programmer
Path: arc1-ca.pugleaf.net!sparky!uunet!charon.amdahl.com!pacbell.com!ames!kronos.arc.nasa.gov!iscnvx!netcomsv!mobdig!johna
From: johna@mobdig.ncal.mobdig.com (John Antypas)
Subject: Need way to monitor actual memory on DOS heap
Message-ID: <1992Oct14.230131.16615@mobdig.ncal.mobdig.com>
Sender: johna@mobdig.ncal.mobdig.com (John Antypas)
Organization: MobileDigital Corp. Alameda CA
Date: Wed, 14 Oct 1992 23:01:31 GMT
Lines: 34