🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.amiga.tech
Article #8991

Re: Free memory available

#8991
From: Marco Papa
Date: Sun, 29 May 1988 07:43
38 lines
2125 bytes
In article <6743@cit-vax.Caltech.Edu> glewis@cit-vax.UUCP (Glenn M. Lewis) writes:
|	What is the "acceptable" way to find out how much memory there is
|in the system from a C program (without AllocMem'ing until a failure)?
|	I want to make a command that takes one argument, a memory size,
|and compares it to the amount of free memory available, and if there is more
|than the argument, it will return a "true" error code, so that I can test
|it with the AmigaDOS command "IF".  (What is a boolean "true" error code
|in AmigaDOS, by the way?) Then, I can say in my startup sequence:
|IF FreeMemory 1Meg THEN
|	Do_something_that_takes_a_lot_of_RAM
|ELSE
|	Just_open_one_window_with_an_editor
|ENDIF

There is a program that has been available since the Amiga inception called 
Availmem or Avail.  I have seen the sources around 2 years ago, and it is 
probably on the FISH disks (Fred?).  It wasn't as fancy as the one that is now
included with AmigaDOS on the Workbench disk, but should be enough for your
purpose.

WARN is easy to use.  "WARN is satisfied if the previous return
code is |= 5" (from the AmigaDOS Users Manual).  So make it return 0 in one
case and 5 in the other one.  The you'll have something like:

MYAVAIL 1M
IF WARN
  DO THIS
ELSE
  DO THAT
ENDIF

Enjoy.

-- Marco Papa 'Doc'
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
uucp:...!pollux!papa       BIX:papa       ARPAnet:pollux!papa@oberon.usc.edu
 "There's Alpha, Beta, Gamma and Diga!" -- Leo Schwab [quoting Rick Unland]
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Technical Details
Message-ID: <9427@oberon.USC.EDU>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!bloom-beacon!oberon!pollux.usc.edu!papa
References: <6743@cit-vax.Caltech.Edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!bloom-beacon!oberon!pollux.usc.edu!papa
From: papa@pollux.usc.edu (Marco Papa)
Newsgroups: comp.sys.amiga.tech
Subject: Re: Free memory available
Message-ID: <9427@oberon.USC.EDU>
Date: 29 May 88 07:43:46 GMT
References: <6743@cit-vax.Caltech.Edu>
Sender: news@oberon.USC.EDU
Reply-To: papa@pollux.usc.edu (Marco Papa)
Distribution: na
Organization: Felsina Software, Los Angeles, CA
Lines: 38