Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!ames!amdcad!sun!pitstop!sundc!seismo!uunet!mcvax!unido!fauern!faui44!mlelstv From: mlelstv@faui44.informatik.uni-erlangen.de (Michael van Elst ) Newsgroups: comp.sys.amiga.tech Subject: Re: free memory defragmentation Message-ID: <691@faui44.informatik.uni-erlangen.de> Date: 20 Oct 88 07:30:28 GMT References: <9887@cup.portal.com> Reply-To: mlelstv@faui44.UUCP (Michael van Elst (kdebugger)) Organization: CSD., University of Erlangen, W - Germany Lines: 31 In article <9887@cup.portal.com> dan-hankins@cup.portal.com writes: >I am considering writing a utility to take the free memory heap and >defragment it. This would involve looking at each of the nodes, reading >them out into a linked list, sorting the linked list, and then >concatenating all the adjacent blocks and then rebuilding the heap. > I am pretty sure that this IS done with a normal FreeMem call since the nodes in the memory free list ARE sorted and we get big chunks of free memory if we free small adjacent blocks before. The problem of fragmentation is another one. It is not small adjacent blocks that aren't concatenated BUT small NOT adjacent blocks that can't be concatenated. The only thing to come around with this, is to collect garbage in memory. But if you do this, you have to correct any absolute memory address in your program and any pointer that refers to a shifted memory block. The MAC OS does this kind of thing as they don't use actual pointers to memory BUT so called 'handles'. These are double referenced pointers. So they only have to held these handles at fixed locations and the OS can easily correct them if the garbage collector has moved memory blocks. Of course, on a multi-tasking machine without MMU, this job is rather difficult as you have to arbitrate access to those handles. The MAC OS simply divides the memory space into large blocks for each application. Thus the amount of memory for each application is fixed. Michael van Elst E-mail: UUCP: ...uunet!unido!fauern!faui44!mlelstv