From: John (john_at_ucc.gu.uwa.edu.au)
Date: 2002-10-07 16:26:01
Ruud writes: >Then this question: what is against moving used blocks to fill up the free >blocks? The only reason I see is that it will cost time. But I could handle >this problem telling the compiler to discard this feature or to execute this >feature only when memory is needed and not enough successive free blocks are >found. The program probably has pointers to the block. If you move it and don't update *all* of the pointers, things are going to fail spectacularly. It's not just pointers to the start of the block that you have to worry about - the block might be a record, and you might have pointers to fields inside it. To do this, you need the cooperation of the compiler, as there's no way you can tell what is a pointer and what isn't by just looking at memory. I'm not aware of any C or Pascal compilers that allow this (with the sort-of exception of the Mac, which requires the programmer to use handles and manually double-indirect everything). It's usually done only with languages that were designed for garbage collection, such as Java. Also, moves are very expensive. You should try to do as few as possible. They're only necessary when memory becomes fragmented, so perhaps only move blocks when the allocator can't find a large enough free block. It's a fairly popular research area. Go googling for "garbage collection", and you'll find so much to read you'll never get the compiler finished... In my opinion, all modern languages should require garbage collection. Pascal, C, and C++ should be forgotten as quickly as possible. Watch how quickly I change my mind when I try implementing it :-) John Message was sent through the cbm-hackers mailing list
Archive generated by hypermail 2.1.4.