Mail Archives: djgpp/2000/09/26/06:15:24
> > Well, I have got sbrk(0) to return negative values in some cases, so the
> > function tells I have -1950Kb.
>
> sbrk returns an insigned value, not a signed one. So negative values
> are actually very large positive ones. Happens a lot on Windows.
So... I cannot use that function I read somewhere to know available memory?
Is there another method?
Suppose I want to write a program that uses a variable size file in various
size computers. I would like to have it in ram if possible, or access it
from disk if I have not enough ram. But if file size is for example 10 Mb
and available ram is 10.5 Mb I don't want to load it.
Perhaps I must try malloc(1.5*filelength(f)) to decide if it is good idea to
load entire file in ram, but I thougth it would be better technique to watch
available before. I think it is possible a long delay for virtual allocation
if I ask for 20 Mb in a 2Mb ram machine, and in this environment I would
prefer to let data on disk and read it myself as necessary, saving real ram
for other more important purposes.
Thanks
Rafael García
- Raw text -