delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/09/26/06:15:24

From: "Rafael García" <rafael AT geninfor DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: RE: negative sbrk(0)
Date: Tue, 26 Sep 2000 11:56:53 +0200
Organization: Telefonica Transmision de Datos
Lines: 28
Message-ID: <8qprpe$l72$1@diana.bcn.ttd.net>
References: <8qns3d$6g4$1 AT diana DOT bcn DOT ttd DOT net> <7263-Tue26Sep2000085518+0300-eliz AT is DOT elta DOT co DOT il>
NNTP-Posting-Host: 193.153.207.32
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2014.211
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2014.211
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

> > 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 -


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