From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15383 invoked by alias); 31 Jul 2008 22:04:46 -0000 Received: (qmail 15374 invoked by uid 22791); 31 Jul 2008 22:04:45 -0000 X-Spam-Check-By: sourceware.org Received: from tully.CS.Berkeley.EDU (HELO tully.CS.Berkeley.EDU) (128.32.153.206) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 31 Jul 2008 22:04:20 +0000 Received: from tully.CS.Berkeley.EDU (localhost [127.0.0.1]) by tully.CS.Berkeley.EDU (8.13.8+Sun/8.13.8) with ESMTP id m6VM4JQM007611 for ; Thu, 31 Jul 2008 15:04:19 -0700 (PDT) Message-Id: <200807312204.m6VM4JQM007611@tully.CS.Berkeley.EDU> To: gdb@sources.redhat.com Subject: GDB to C++ issue: deletion Reply-To: Hilfinger@CS.Berkeley.EDU In-reply-to: Your message of Thu, 31 Jul 2008 12:07:32 +0200. <1217498852.4594.30.camel@piko.site> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <7607.1217541859.1@tully.CS.Berkeley.EDU> Date: Thu, 31 Jul 2008 22:30:00 -0000 From: Paul Hilfinger Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2008-07/txt/msg00355.txt.bz2 Alpar wrote: > A good example for that was the debate on xfree vs. delete. One of the > goals of STL standard containers is that using them the programmer will > almost never has to use 'delete'. This reminded me of an issue that I'd be curious to see discussed. The STL container classes are certainly convenient for decreasing memory leaks with little fuss, but they do so internally with individual frees of allocated items. GDB currently does much of its allocation using a region-based style (in the form of obstacks). This reduces leakage at some expense in safety (although I have not seen many dangling-pointer problems triggered premature obstack releases in GDB). Allegedly, GDB's use of obstacks significantly speeds up allocation and (of course) deletion. I have certainly seen programs in which the need to free data structures individually adds significant cost*. The STL container classes provide for allocators, but I have no experience in how well they could be made to work in duplicating GDB's current performance in this area. I'd be interested in hearing the thoughts of the C++ lobby. Paul Hilfinger * In the really old days (before some contributors to this list were born, I suspect), I used Brian Reid's Scribe program as a text formatter. It would print out a progress report in the form of a sequence of page numbers, as LaTeX does now. I noticed that after it reported printing the last page, there would be a VERY long pause before the program finally exited (the longer the document, the longer the pause) . Sure enough, this was Brian's carefully hand-crafted automatic storage reclamation mechanism painstakingly releasing all the data structures (pointlessly, of course, since then as now, the OS deallocated program storage en masse on exit).