www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/11/16/22:23:25

Date: Sun, 16 Nov 1997 19:21:55 -0800 (PST)
Message-Id: <199711170321.TAA02316@adit.ap.net>
Mime-Version: 1.0
To: "Seth Hill" <ferris AT proaxis DOT com>, djgpp AT delorie DOT com
From: Nate Eldredge <eldredge AT ap DOT net>
Subject: Re: How much free memory ?

At 03:02  11/13/1997 -0800, Seth Hill wrote:
>On Thu, Nov 13, 1997 8:10 PM, Marian Lysak <mailto:xlysak AT fi DOT muni DOT cz>
>wrote:
>>I would like to know if anybody know how could I get 
>>amount of free memory in DJGPP.
>>---------------------
>>
>>In Borland C 3.1 is function [ coreleft() ] in alloc.h header file,
>>but in DJGPP I couldn't find any function like this one.
>>
>>If you can answer to my e-mail address please.
>>
>>Thanks for all answers !
>>
>>Marian Lysak <xlysak AT fi DOT muni DOT cz>
>>
>
>Try:
>
>#include <dpmi.h>
>
>int get_free_mem( void )
>{
>    __dpmi_free_mem_info info;
>    __dpmi_get_free_memory_information( &info );
>    return info.largest_availible_free_block_in_bytes;
>}
This may be misleading, since the amount of memory remaining may be much
greater than the largest available block. (You might get a value of `10000',
but be able to `malloc(5000)' many many times.) Also, it isn't even the
largest amount you can `malloc()', because of `malloc()'s overhead. So you
can use that function if you want, but IMHO, the only thing that has any
meaning is whether or not `malloc()' returns NULL.

Nate Eldredge
eldredge AT ap DOT net



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019