Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!EDDIE.MIT.EDU!compass!worley From: compass!worley@EDDIE.MIT.EDU (Dale Worley) Newsgroups: gnu.emacs Subject: Why Gnu Emacs doesn't release memory Message-ID: <8910261557.AA02573@sn1987a.compass.com> Date: 26 Oct 89 15:57:06 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 32 Gnu Emacs uses memory in a dynamically allocated manner. Memory tends to be allocated in small chunks (list cells, small strings) and in large chunks (buffers, large strings). (To prevent various problems, small chunks are suballocated out of large chunks that are reserved for this purpose.) Memory becomes free in more-or-less random order, so the memory space tends to be a mosaic of free and in-use areas. Most Unix systems allow the user to change his memory allocation only by enlarging or shrinking the data area, and then only by moving the high-address end. However, the high-address end of the data area is likely to be a mosaic of free and in-use areas, and so it is very unlikely that its end can be moved down by much at any time, even if a large fraction of the data area is free. Thus, there is no utility in designing a mechanism to detect and free memory from the address space. (If the kernel provided a mechanism to free interior parts of the data area address space, it might be worthwhile for Emacs to deallocate large free chunks.) The traditional solution to such problems is called 'compactification' -- moving all in-use data areas into a compact mass at the low end of the data area, and then deallocating the huge free area left at the high end. To do this successfully requires that all pointers to any data area be altered to point to the new addresses, which (despite some earlier speculations of mine) requires much careful design and is very error-prone. Dale Worley Compass, Inc. worley@compass.com -- All through human history, tyrannies have tried to enforce obedience by prohibiting disrespect for the symbols of their power. The swastika is only one example of many in recent history. -- American Bar Association task force on flag burning