Path: utzoo!utgpu!watmath!clyde!att!pacbell!ames!mailrus!tut.cis.ohio-state.edu!bloom-beacon!oberon!nunki.usc.edu!castor.usc.edu!raddison From: raddison@castor.usc.edu (Richard Addison) Newsgroups: comp.sys.amiga.tech Subject: Re: Memory Allocation Question Summary: The lowdown on memory allocation Keywords: AllocMem,MEMF_FAST Message-ID: <2077@nunki.usc.edu> Date: 3 Dec 88 11:35:24 GMT References: <155@bhpese.bhpese.oz> Sender: news@nunki.usc.edu Reply-To: raddison@castor.usc.edu (Richard Addison) Organization: University of Southern California, Los Angeles, CA Lines: 39 In <155@bhpese.bhpese.oz> andrew@bhpese.bhpese.oz (Andrew Steele) writes: >This is a quick question. >If in a program you have the following statement : > > ptr = AllocMem( 100L , MEMF_FAST ); > >how will the Amiga handle the case when the is no fast ram left ? > >I would think that a lack of fast ram would cause chip ram to be allocated >but I can't find anywhere that explicitly says that this is the case. If you ask for MEMF_FAST, you will only get memory that is identified as FAST; if you ask for MEMF_CHIP, you will only get CHIP memory; if you ask for MEMF_PUBLIC, you will get PUBLIC memory. Note that these are not strictly mutually exclusive. Granted, in the current system design, CHIP and FAST are distinct, but AllocMem would operate happily on a MemHeader that is marked both CHIP and FAST. In fact, all memory on the Amiga is now marked PUBLIC as well as either CHIP or FAST. (Aside: I sure hope anyone who wants their software to survive any upgrade to an MMU version of Exec pays strict attention to allocating shared data objects in PUBLIC memory!) Now back to what you really want: Try: if (!(ptr = AllocMem(100L,MEMF_FAST))) ptr = AllocMem(100L,0L); So, if there isn't a block of FAST memory that satisfies your request, you ask for any old block of memory! Be aware that AllocMem will try to purge Libraries and Devices that are not currently open before it returns a NULL pointer. Richard Addison (Remember that episode of Gilligan's Island where they almost got of the island?)