From: bj@cbmvax.commodore.com (Brian Jackson - Amiga Networking)
Newsgroups: comp.sys.amiga.programmer
Subject: Re: Flushing Devices; C= doco (mutter!)
Date: 8 Jan 93 19:01:10 GMT
Reply-To: bj@cbmvax.commodore.com (Brian Jackson - Amiga Networking)
Organization: Commodore, West Chester, PA

In article <crystal.726454269@glia> crystal@glia.biostr.washington.edu (Crystal) writes:
>In <1iia8tINNdeh@darkstar.UCSC.EDU> davids@cats.ucsc.edu (Dave Schreiber) writes:
>
>
>>In article <1993Jan7.092127.13752@philips.oz.au> gduncan@philips.oz.au (Gary Duncan) writes:
>>>Passing thought ; why the heck aren't unused libraries/devices
>>>flushed automatically anyway? Sounds like a legacy of the days 
>>>when hard disks were rare and dragging a device off floppy was
>>>time-consuming. Those days are gone...
>
>>Why should they be flushed?  An unused library essentially takes up
>>zero memory, since the memory it uses can be demanded from it at
>
>Then how come running "avail flush" returned 75k of memory to me if they
>take up ZERO memory...?
>
>>any time (and will be demanded from it before a memory allocation
>>is allowed to fail).  The only people for whom auto-removal of
>>libraries is important are developers who are checking for memory
>
>Warning: you are dealing in absolutes here... developers are not the ONLY
>people for whom auto-removal of libraries is important.  Those with
>little ram trying to run DTP programs or Database programs that access
>large textfiles or graphics likewise need to be able to have as much memory
>available to them as possible for their work, too.  
>
>>leaks; there are plenty of ways of flushing libraries on those
>>rare occassions when it is needed.
>
>Ok, so, other than "avail flush", what other ways are there?  I want to
>recover as much as I can from those programs that don't clean up after
>themselves.

You have a fundamantal misunderstanding of how this all works.  Libraries,
devices, fonts, etc all stay in memory after use so that if someone needs
them later on they are already in place and don't need to be reloaded again
and again. But all of these things have internal user counts that are zero
if no one has them open at the time.  That means that the system can 'know'
what things can be deleted from memory if another program needs the ram
space.  So, if you run up an application that needs a bunch of memory
(more than is currently available as shown by 'avail') the system will try
to flush everything with a zero user count.  Anything that gets flushed by
doing an 'avail flush' will be flushed by the system under these conditions. 

As for wanting to "recover as much as I can from those programs that don't 
clean up after themselves" the fact is that the system can do nothing
about application resources that are not returned by the applications.
An 'avail flush' simply forces the system to do what it would do _anyway_
once you ran up your DTP program.

       +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +
       Brian Jackson    Amiga Networking Group, Commodore-Amiga Inc.
                        bj@cbmvax.commodore.com
     {uunet|rutgers}!cbmvax!bj    or   networking@cbmvax.commodore.com
                       uva uvam vivendo varia fit