Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!srcsip!nic.MR.NET!hal!ncoast!allbery From: allbery@NCoast.ORG (Brandon S. Allbery) Newsgroups: comp.emacs Subject: Re: why does GNU Emacs not release memory Message-ID: <1989Oct31.020817.28440@NCoast.ORG> Date: 31 Oct 89 02:08:17 GMT References: <1989Oct26.150344.10013@talos.uucp> Reply-To: allbery@ncoast.ORG (Brandon S. Allbery) Followup-To: comp.emacs Organization: North Coast Public Access UN*X, Cleveland, OH Lines: 50 As quoted from by jkh@meepmeep.pcs.com (Jordan K. Hubbard): +--------------- | I think the real answer is that yes, this can be done with a good | malloc() package and little or no modification to the application, no it's | not easy to do it right (and stay portable) so it has not been done | (at least to my knowledge). +--------------- It can be done, sort of, by tagging memory allocated by Lisp somehow and compacting that memory. The problem is that you must compact memory before handing any out to a malloc() *not* for Lisp (e.g. for the X library or etc.), or you risk ending up unable to compact beyond a chunk of memory which cannot be moved without making emacs dump core: +--------------------+ | initialized data | +--------------------+ | uninitialized data | +--------------------+ | Xlib memory | +--------------------+ | | | Lisp pool | | | +--------------------+ | something in Xlib | +--------------------+ | compactible memory | +--------------------+ You can't relocate the memory unless you can go in and change pointers to it, which is only possible in areas where you have complete control of the memory (e.g. the Lisp memory allocator). Worse, even if you do compact before servicing a malloc() for something other than the Lisp memory allocator, you can end up with sizeable gaps if the user kills a large buffer after the malloc(). The only way to do it right is to write your own versions of libraries that use malloc() and make them use something that can easily be adjusted, like the "handles" used by the Mac (flames to /dev/null) and Mis-Windows. In other words, it can be done up to a point, but it won't do all that much good. ++Brandon -- Brandon S. Allbery: allbery@NCoast.ORG, BALLBERY (MCI Mail), ALLBERY (Delphi) uunet!hal.cwru.edu!ncoast!allbery ncoast!allbery@hal.cwru.edu bsa@telotech.uucp *(comp.sources.misc mail to comp-sources-misc[-request]@backbone.site, please)* *Third party vote-collection service: send mail to allbery@uunet.uu.net (ONLY)* >>> Shall we try for comp.protocols.tcp-ip.eniac next, Richard? <<<