Xref: utzoo alt.sources.amiga:235 comp.sys.amiga.programmer:3393 Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!snorkelwacker.mit.edu!bloom-beacon!eru!hagbard!sunic!liuida!micja From: micja@ida.liu.se (Michael Jansson) Newsgroups: alt.sources.amiga,comp.sys.amiga.programmer Subject: Re: Short Hello World Message-ID: <1991May8.091019.25188@ida.liu.se> Date: 8 May 91 09:10:19 GMT References: <1991Apr30.213936.22878@ux1.cso.uiuc.edu> <1991May2.102554.8679@cs.umu.se> <1200@cbmger.UUCP> <1991May4.134045.7550@cs.umu.se> <1205@cbmger.UUCP> Sender: news@ida.liu.se (News Subsystem) Organization: CIS Dept, Univ of Linkoping, Sweden Lines: 46 In article <1205@cbmger.UUCP> peterk@cbmger.UUCP (Peter Kittel GERMANY) writes: [Stuff deleted about small 'Hello'-programs] >Well, we had a lengthy discussion on this in the German sub.sys.amiga >group. We came to the conclusion that it would really be dangerous! >Because, if your Amiga runs long enough and runs such programs in a >tight loop, the use counter of the library will be increased every time. >And, after *some* (:-) time, it will wrap around to zero. And, if it >happens that you have a tight memory situation just in this moment and >exec flushes all unused libs: POOF! I admit, not an everyday scenario, >but sure possible :-). That is not really true (unless I got it all backwards). A library will stay resident until there is a shortage of memory AND the Expunge function (every library has one), which is called when Exec attempts to remove the un-used library, returns the segment of the library itself. In other words - The library is only flushed if the library admits it, which might not be the case for the ROM-based libraries (my guess is that they are un-removable since they are never loaded with LoadSeg). I have used this feature in a library of mine. The library will eat a lot of memory, which can be returned to the system if needed. I managed to do this by writing a neat little garbage collector and put it where the Expunge function should be. I also bookkeep the number of users of the library separately, i.e. not in the library structure that Exec knows of, so that Exec will be convinced that the library is unused when it is not. So what will this give me? Exec will attempt to remove the library whenever there is a shortage of memory which will result in a call to my new Expunge function, that will return some memory without removing itself, i.e. an automatic GC. It works too! (At least so far ;-). [Other stuff deleted] >-- >Best regards, Dr. Peter Kittel // E-Mail to \\ Only my personal opinions... >Commodore Frankfurt, Germany \X/ {uunet|pyramid|rutgers}!cbmvax!cbmger!peterk -- ########################################################## # Michael Jansson | \_/ # Internet: mij@IDA.LIU.SE | V _|_ # UUCP: uunet!liuida!mij | | Absolut Software| # BITNET: mij@SELIUIDA | ~~~