Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!killer!ames!oliveb!amiga!jimm From: jimm@amiga.UUCP (Jim Mackraz) Newsgroups: comp.sys.amiga.tech Subject: Re: free memory defragmentation Message-ID: <3009@amiga.UUCP> Date: 11 Oct 88 23:14:52 GMT References: <9887@cup.portal.com> Reply-To: jimm@cloyd.UUCP (Jim Mackraz) Organization: Commodore-Amiga Inc, Los Gatos CA Lines: 50 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. The list is sorted, and adjacent blocks are concatenated, all of the time. )This seems like such a simple idea, it amazes me that it has not occurred )to anyone before. Has it? Would I be re-inventing the wheel? I think Carl thought of it, too. )If so, where could I find this utility? I have a need for it. It is called FreeMem(), a function of the Exec in ROM. ;^) )If no one has written one before, is there some quirk of the opsys that )would prevent me from doing it? You could call it a quirk, I guess. )I already envision that the second version would intercept calls to )the system allocation and de-allocation functions and run in the background, )only doing the de-fragmentation when a block is returned to the heap or )when an allocation request fails. FreeMem(). )Dan Hankins jimm By the way: memory fragmentation on the Amiga occurs because there are actually allocated sections of memory between the freed chunks. There's been a lot of discussion on this already. Note that you can't concatenate two non-adjacent chunks. If you think you have identified a condition where there are adjacent free chunks in the free list (or an unsorted free list), please reproduce and mail in a floppy. I don't think so, though. -- Jim Mackraz, I and I Computing amiga!jimm BIX:jmackraz Opinions are my own. Comments regarding the Amiga operating system, and all others, are not to be taken as Commodore official policy.