🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Need way to monitor actual memory on DOS heap

#3814
From: Misha Verplak
Date: Fri, 16 Oct 1992 02:24
34 lines
1789 bytes
johna@mobdig.ncal.mobdig.com (John Antypas) writes:

>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?

When DOS frees memory of SIZEB, it is left with SIZEA | free | SIZEC | free
and so the _contiguous_ memory available starts after SIZEC.

Misha.
Technical Details
Message-ID: <int559r.719202281@aurora.cc.monash.edu.au>
Path: arc1-ca.pugleaf.net!sparky!uunet!pipex!unipalm!uknet!stl!bnrgate!nrcnet0!cunews!torn!utcsri!rutgers!sgigate!sgiblab!munnari.oz.au!bruce.cs.monash.edu.au!monu6!aurora.cc.monash.edu.au!int559r
References: <1992Oct14.230131.16615@mobdig.ncal.mobdig.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!pipex!unipalm!uknet!stl!bnrgate!nrcnet0!cunews!torn!utcsri!rutgers!sgigate!sgiblab!munnari.oz.au!bruce.cs.monash.edu.au!monu6!aurora.cc.monash.edu.au!int559r
From: int559r@aurora.cc.monash.edu.au (Misha Verplak)
Newsgroups: comp.os.msdos.programmer
Subject: Re: Need way to monitor actual memory on DOS heap
Message-ID: <int559r.719202281@aurora.cc.monash.edu.au>
Date: 16 Oct 92 02:24:41 GMT
References: <1992Oct14.230131.16615@mobdig.ncal.mobdig.com>
Sender: news@monu6.cc.monash.edu.au (Usenet system)
Organization: Monash University, Melb., Australia.
Lines: 34