Date: Sun, 16 Nov 1997 19:21:55 -0800 (PST) Message-Id: <199711170321.TAA02316@adit.ap.net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" To: "Seth Hill" , djgpp AT delorie DOT com From: Nate Eldredge Subject: Re: How much free memory ? Precedence: bulk At 03:02 11/13/1997 -0800, Seth Hill wrote: >On Thu, Nov 13, 1997 8:10 PM, Marian Lysak >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 >> > >Try: > >#include > >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