From: Eric Hodel Date: 2006-08-29T08:26:43+09:00 Subject: Re: Can Anyone Explain This Memory Leak? On Aug 26, 2006, at 5:14 AM, Zed Shaw wrote: > On Fri, 2006-08-25 at 16:10 +0900, ara.t.howard@noaa.gov wrote: >> On Fri, 25 Aug 2006, Zed Shaw wrote: >> >>> And where are you getting your information that free doesn't free >>> memory? I'd like to read that since all my years of C coding >>> says that >>> is dead wrong. Care to tell me how malloc/free would report 80M >>> with >>> Mutex but properly show the ram go down when there is no-Mutex? >> >> a nice explanation: >> > >> http://groups.google.com/group/comp.unix.programmer/browse_frm/ >> thread/23e7be26dd21434a/2f84b3dc080c7519?lnk=gst&q=memory+not >> +really+freed&rnum=9#2f84b3dc080c7519 >> >> the paper referenced is also good. >> >> ftp://ftp.cs.utexas.edu/pub/garbage/allocsrv.ps > > So, a posting to a news group from some guy in 2001 (5 years old) > and a > paper written in 1995 (11 years old) that has references to papers as > old as 1964, none of which say that measurements of RAM will behave as > I've demonstrated *today*. brk and sbrk are still used, for example, phkmalloc: http://www.freebsd.org/cgi/cvsweb.cgi/src/lib/libc/stdlib/malloc.c? rev=1.90.2.1&content-type=text/x-cvsweb-markup&only_with_tag=RELENG_6 phkmalloc returns memory to the OS when an entire page is clean. In Ruby a page may not always be clean because ruby heap slots may be scribbled upon it. See add_heap in gc.c: http://www.ruby-lang.org/cgi-bin/cvsweb.cgi/ruby/gc.c? rev=1.168.2.45;content-type=text%2Fx-cvsweb- markup;only_with_tag=ruby_1_8 A good way to test this theory would be to either increase the number of items per ruby heap slot by editing gc.c and recompiling, or using many more threads. (Maybe I will do that.) The real difference may be that Sync and Mutex have different memory usage profiles. -- Eric Hodel - drbrain@segment7.net - http://blog.segment7.net This implementation is HODEL-HASH-9600 compliant http://trackmap.robotcoop.com