From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.50.138.167 with SMTP id qr7mr9614igb.6.1409776248965; Wed, 03 Sep 2014 13:30:48 -0700 (PDT) Path: border1.nntp.dca1.giganews.com!nntp.giganews.com!r2no13796974igi.0!news-out.google.com!aw9ni8667igc.0!nntp.google.com!peer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!nntp.club.cc.cmu.edu!micro-heart-of-gold.mit.edu!newsswitch.lcs.mit.edu!nntp.TheWorld.com!.POSTED!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: newbie: can't read fast enough... :-) memory leaks... Date: Wed, 03 Sep 2014 16:31:12 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <479b2efe-0238-4b2a-8b05-cb1a0b4a57e5@googlegroups.com> <1409739464.7121.235.camel@obry.net> <1thd1r1lwpfn0$.pcupzjcl3iga.dlg@40tude.net> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 X-Trace: pcls7.std.com 1409776247 24696 192.74.137.71 (3 Sep 2014 20:30:47 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Wed, 3 Sep 2014 20:30:47 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:IqmU5+tGkHJBZfR/obHrs2bAypY= X-Received-Bytes: 2443 X-Received-Body-CRC: 2382075067 Content-Type: text/plain; charset=us-ascii Xref: number.nntp.dca.giganews.com comp.lang.ada:188846 Date: 2014-09-03T16:31:12-04:00 List-Id: "Dmitry A. Kazakov" writes: > On Wed, 03 Sep 2014 13:28:22 -0400, Robert A Duff wrote: > >> I have successfully used the BDW conservative garbage collector with >> Ada. > > Could you sketch out how you did the mark phase? BDW = Boehm-Demers-Weiser. I didn't write it, so I didn't "do the mark phase". There's lots of info available via "google boehm gc", if you want to know how it works. Boehm's documentation is very well written. As I recall, it first finds all the thread stacks, which is an OS-dependent operation. Those are the "roots". It looks at each word in the stacks, using supposedly-conservative heuristics to guess whether that word is a pointer. If so, it traces that, and follows all the pointers in the heap object, transitively. It uses "black listing" to avoid too many wrong guesses. For example, if you have a string containing "Hello, w" that's not a pointer. It treats that as a 64-bit number (e.g. on x86-64), and checks whether that memory location is currently allocated. If so, it assumes it's a pointer (which is a wrong guess). But if not, it guesses correctly that this data is not a pointer, and also puts that memory location on a black list, and never allocates anything there -- that way, it will not guess wrong in the future. There are all sorts of other tricks to avoid guessing wrong. - Bob