Mail Archives: djgpp/1999/09/25/20:55:18
From: Ghalos <greg AT holdridge7 DOT freeserve DOT co DOT uk>
> To: djgpp AT delorie DOT com
> Subject: Memory hoarding
> Date: Saturday, September 25, 1999 7:39 PM
>
> When my game starts up I am thinking of grabbing all the available memory I
> can but one thing I need to is what is the best way of doing this? I seem
> to remember from experiments that the value returned by the maximum block
> size function is different from what I could actually allocate by trial and
> error. Why is that?
>
> Any help appreciated,
> --
> Ghalos - greg AT holdridge7 DOT freeserve DOT co DOT uk
>By available memory do you mean both physical and virtual or just physical (ie
the amount of hard ram on your computer). Section 15.2 of the FAQ gives some
help on getting the amount of free ram but various DPMI servers sometimes
return wrong values. The amount of free memory available might be more than
that returned by the _go32_available_*****_memory functions because recently
freed memory is not returned to the system.
My method for grabbing all available physical memory is to set up a loop wich
allocates memory in chuks of 100K and it also attempts to lock the memory. If
the allocation fails we have run out of ram and we can calculate the free ram
by finding how many total 100k blocks we allocated. If you cant lock the 100K
block that means the DPMI server has allocated virtual memory and like above we
can calcualte the physical ram.
Then I can free up the memory and allocate it in a single chunk using sbrk().
I have also wonderd how Quake 1 wich uses djgpp gets the free memory values it
prints at startup.
I hope this helps you my friend. Please tell me any ideas about my method.
Kalum <kalum AT myflat DOT com>
_____________________________________________
Free email with cool domains at FriendlyEmail
http://www.mypad.com/
- Raw text -