To: max AT alcyone DOT com Cc: djgpp AT delorie DOT com Subject: Re: Bug in malloc/free ? Message-ID: <19970306.200419.4511.3.fwec@juno.com> References: <5fm6r7$6av$1 AT gjallar DOT daimi DOT aau DOT dk> <331EF4EF DOT 3788CF9D AT alcyone DOT com> From: fwec AT juno DOT com (Mark T Logan) Date: Thu, 06 Mar 1997 20:06:40 EST On Thu, 06 Mar 1997 08:46:39 -0800 Erik Max Francis writes: >It's possible (though I haven't checked) that memory is becoming too >fragmented from the allocations and frees, so that eventually it >fails. I think Eric is perfectly right here, but I feel the need to elaborate. Fragmented memory is when you have lots of little memory blocks all over. What happens because of this is that the largest free chunk of memory might be only 10K in size. You can have megs and megs of free memory, but you can't allocate 11K anymore. One solution is to write your own memory manager. The memory manager must use "garbage collection." I beleive that Lisp has a manager like this built in. CMIIW. Anyway, garbage collection simply means that the manager will take all the allocated blocks, and smash them all into one contigous block. The only catch is that your manager can't give out addresses when you call its allocation function. This is because if it goes and collects the garbage, all the addresses change. So, you have to give out handles. A handle is the address of a location in memory where you have stored the address of an allocated block. This means that your manager has the one and only copy of the chunks address, and can change the address when it moves a chunk. If you want more info, I am working on just such a manager, which will be part of a larger package of memory tools, to be distributed under the name "SuperMem." I plan to release an alpha version for comments and suggestions later this month. I would be happy to mail you the source code, but I don't have an awful lot written right now. Good luck. || Fwec AT juno DOT com aka Mark Logan aka Gil Bates || || This message was a work of fiction. As such, all characters contained in || said message are purely fictitious. Any resemblence to actual persons, living || or dead, is purely coincidental.