home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / cplus / 13092 < prev    next >
Encoding:
Text File  |  1992-08-31  |  2.0 KB  |  43 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!gatech!darwin.sura.net!convex!news.utdallas.edu!corpgate!crchh327!bnr.ca!holiday
  3. From: holiday@bnr.ca (Matthew Holiday)
  4. Subject: Re: Garbage Collection for C++
  5. Message-ID: <1992Aug31.152016.25173@bnr.ca>
  6. Sender: holiday@crchh82 (Matthew Holiday)
  7. Nntp-Posting-Host: crchh82
  8. Reply-To: holiday@bnr.ca
  9. Organization: Bell-Northern Research, Richardson, TX
  10. References: <DAVEG.92Aug20043156@synaptx.synaptics.com> <28623@vedge.UUCP> <DAVEG.92Aug28004331@synaptx.synaptics.com> <23580@alice.att.com>
  11. Date: Mon, 31 Aug 1992 15:20:16 GMT
  12. Lines: 29
  13.  
  14. In article <23580@alice.att.com>, ark@alice.att.com (Andrew Koenig) writes:
  15. |> 
  16. |> I think the right answer, at least for most practical purposes, is to
  17. |> say that the purpose of garbage collection is to simulate unbounded
  18. |> memory.  Once an object has become garbage, there is no way to tell
  19. |> whether that memory is still in use, so the implementation should be
  20. |> allowed to reclaim it without explicitly destroying the object.
  21. |> As a programmer, you shouldn't care; you have no way of finding out that
  22. |> it happened.
  23. |> 
  24.  
  25. One of the things that makes GC attractive is the need to reclaim memory that
  26. might be leaked during exception handling.  Imagine that a function allocates
  27. an array with new [], and then an exception transfers control to a scope which
  28. isn't prepared to delete that array.  Unless there is strong coupling between
  29. exception handlers and try blocks (i.e., every potential handler for a exception
  30. knows about the places the exception may originate, and the need for store
  31. reclamation), there will be memory leaks resulting from exceptions.  One way
  32. to deal with this is for every try block to have a catch block for every
  33. exception type, in which all cleanup takes place, and then re-throws the
  34. exception to a handler which can actually act on the exception type.  Its not
  35. particularly elegant, but perhaps would work.
  36.  
  37. Any ideas?
  38.  
  39. -- 
  40. Matt Holiday                                      #include <std/disclaimer>
  41. holiday@bnr.ca
  42. BNR Richardson, TX
  43.