Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Pb with free memory detection

1 view
Skip to first unread message

Eric NICOLAS

unread,
Mar 5, 1996, 3:00:00 AM3/5/96
to

Using: DJGPP V2.0

Hi djgpp gurus !

I have a little problem when I want to detect available memory with
djgpp V2. (I think this is about the same with v1.12m4).

Here is a little program that demonstrate the problem. The values returned
by the prog are quite strange. look by yourself.

Are there ather ways to get available memory ?

Thanks.

-- Sample program memory.cc ----------

#include <stdlib.h>
#include <dpmi.h>
#include <stdio.h>

void PrintFreeMem(void)
{ printf("Free Physical memory : %uld bytes\n",_go32_dpmi_remaining_physical_memory());
printf("Free Virtual memory : %uld bytes\n",_go32_dpmi_remaining_virtual_memory());
}

int main()
{ printf("MEMORY free test - DJGPP compiler\n");
PrintFreeMem();
printf("\nAllocation 34658 bytes...\n\n");
char *Dummy=(char*)malloc(34658);
PrintFreeMem();
printf("\nFreeing the memory allocated\n\n");
free(Dummy);
PrintFreeMem();
printf("\nDone.\n");
return 0;
}

--
Eric Nicolas <nic...@dsys.ceng.cea.fr>

Eli Zaretskii

unread,
Mar 6, 1996, 3:00:00 AM3/6/96
to Eric NICOLAS, dj...@delorie.com

On 5 Mar 1996, Eric NICOLAS wrote:

> Here is a little program that demonstrate the problem. The values returned
> by the prog are quite strange. look by yourself.

The programs you posted work as they should. Why? This is explained in
the DJGPP FAQ list (available in the file faq200b.zip from the same place
you get DJGPP), section 15.2. Or point your Web browser to this URL:

http://www.delorie.com/djgpp/v2faq/faq087.html#Confusing alloc

and read that section on-line.

0 new messages