This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GDB to C++ issue: deletion


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).



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]