[comp.sys.mac.programmer] memTop, or how much RAM?

rfl@oddjob.uchicago.edu (Bob Loewenstein) (12/28/89)

memTop in machines other than mac+ and xl gives the amount of
memory available to the application. I need to find out how
much memory is available in the particular machine my application
is running on. I must be missing something...Can anyone clue me
in on what to do? Thanks

rfl@oddjob.uchicago.edu (Bob Loewenstein) (12/28/89)

My last question may have been confusing..I need to know how much
Ram is installed in the machine. Occasionally my application interprets
a variable as pointer and before accessing memory perhaps pointed to, I 
want to be sure that the "pointer" is pointing to a valid address.

beard@ux1.lbl.gov (Patrick C Beard) (12/28/89)

In article <6886@tank.uchicago.edu> rfl@oddjob.uchicago.edu (Bob Loewenstein) writes:
>
>My last question may have been confusing..I need to know how much
>Ram is installed in the machine. Occasionally my application interprets
>a variable as pointer and before accessing memory perhaps pointed to, I 
>want to be sure that the "pointer" is pointing to a valid address.

Well, the safest thing to do would probably check that the pointer 
points to a valid address in your OWN heap, or the System heap, and all
other addresses aren't safe because they point to some other application's
heap.

However; you might for some reason wish to find out (if your were writing
a utility that does diagnostics or whatever) the extent of physical RAM.
I believe that the call MFTopMem gives you the address of the highest
useable byte in memory.

From the MPW interfaces:

pascal Ptr MFTopMem(void) = {0x3F3C,0x0016,0xA88F};

This is available on all systems beyond 6.0.
-------------------------------------------------------------------------------
-  Patrick Beard, Macintosh Programmer                        (beard@lbl.gov) -
-  Berkeley Systems, Inc.  ".......<dead air>.......Good day!" - Paul Harvey  -
-------------------------------------------------------------------------------