Messages in this thread |  | | Date | Wed, 29 Jan 1997 12:18:23 +0100 | From | Wolfram Gloger <> | Subject | Re: Memory use: returning freed memory to the pool |
| |
Theodore Ts'o:
> It depends on the malloc/free implementation. In fact the malloc() > which is in the Linux libc will return virtual memory to the OS. > > HOWEVER, malloc() can only return memory if if there is a contiguous > chunk of memory just below brk that it can give back to the system. > With X, sometimes this just doesn't happen.
Yes, exactly, for example large pixmaps can become `locked' between smaller, long-lived allocated chunks. But this problem was solved by using mmap() for large allocations. The XFree86 servers come with a special malloc that does this, but IMHO it is better to just use dl-malloc in libc-5.4.x, which has been carefully tuned for performing well with X server allocation patterns.
> 4. Xinside's server uses their own version of malloc/free, which actually > unmaps memory which has been freed, once it exceeds a certain limit or > something. > > If I understand things correctly, Xinside does more than this --- they > actually use a garbage collecting-like scheme where they will actually > rearrange allocated memory (by mucking with pointers) so that there's a > chunk of memory they can give back.
Since the code isn't available, this is all speculation, but I doubt they can do much better than the current code in libc does -- for a long XFree86 server (compiled without the provided malloc) session I measured a heap waste of less than 12% of allocated memory. This is rather low.
> At one point there was someone who was experimenting with a version of > malloc() which used mmap in a clever way to try to make it more easy to > release memory back to the system.
This isn't experimental any more. It has been in Linux libc for more than a year now, and seems to work very well.
> There are some real framentation > overhead and page boundary overheads that have to be considered, > though. It's not a trivial problem.
Yes; I've submitted an abstract for the Linux congress on this.. :)
> It's much easier when you put a lot of cleverness into the application > program, which is what X Inside does with its server.
Easier for the libc developer, yes, but it's much easier for the application developer if there is an excellent `allround' malloc implementation in libc so you don't have to come up with special-purpose code for every other program. In the Linux system libs, I think this goal has been achieved.
Regards, Wolfram. -- `Surf the sea, not double-u three...' Wolfram.Gloger@dent.med.uni-muenchen.de, Gloger@lrz.uni-muenchen.de
|  |