|
Archives
D Programming
DD.gnu digitalmars.D digitalmars.D.bugs digitalmars.D.dtl digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript |
D - delete throws ReferencesRemainException?
Walter has noted that operator delete may be used to force immediate garbage collection, particularly for situations where you either must run the destructor now or when the object is a massive amount of memory you want to release. I would think that the garbage collector should check at this time and not allow deletion if other references exist. Thus, delete should throw "ReferencesRemainException" if there are any remaining references (other than the one used to call delete). This would ensure garbage-collection correctness while also allowing the programmer a powerful cleanup tool. Thoughts? -- The Villagers are Online! http://villagersonline.com .[ (the fox.(quick,brown)) jumped.over(the dog.lazy) ] .[ (a version.of(English).(precise.more)) is(possible) ] ?[ you want.to(help(develop(it))) ] Nov 11 2001
Russ Lewis wrote:Walter has noted that operator delete may be used to force immediate garbage collection, particularly for situations where you either must run the destructor now or when the object is a massive amount of memory you want to release. I would think that the garbage collector should check at this time and not allow deletion if other references exist. Thus, delete should throw "ReferencesRemainException" if there are any remaining references (other than the one used to call delete). This would ensure garbage-collection correctness while also allowing the programmer a powerful cleanup tool. Thoughts? Nov 11 2001
I believe most garbage collectors also aren't foolproof... if it wasn't using reference counts, you don't want it throwing an exception just because there's some bit of data somewhere that looks an awful lot like a pointer to the thing you're deleting. Sean "Russ Lewis" <spamhole-2001-07-16 deming-os.org> wrote in message news:3BEF5596.15595EAA deming-os.org...Walter has noted that operator delete may be used to force immediate garbage collection, particularly for situations where you either must run the destructor now or when the object is a massive amount of memory you want to release. I would think that the garbage collector should check at this time and not allow deletion if other references exist. Thus, delete should throw "ReferencesRemainException" if there are any remaining references (other than the one used to call delete). This would ensure garbage-collection correctness while also allowing the programmer a powerful cleanup tool. Thoughts? Nov 12 2001
It is a great idea, but it has implementation problems. The trouble is: 1) it is expensive to scan for references - almost as expensive as doing a full garbage collection run. 2) sometimes references are ambiguous, and it would be an error to raise an exception based on that A better way is to use what I call a "memory stomper". The delete operation will "stomp" on the object's data (filling it with FF's), so that any dangling references to it will surely fail. "Russ Lewis" <spamhole-2001-07-16 deming-os.org> wrote in message news:3BEF5596.15595EAA deming-os.org...Walter has noted that operator delete may be used to force immediate garbage collection, particularly for situations where you either must run the destructor now or when the object is a massive amount of memory you want to release. I would think that the garbage collector should check at this time and not allow deletion if other references exist. Thus, delete should throw "ReferencesRemainException" if there are any remaining references (other than the one used to call delete). This would ensure garbage-collection correctness while also allowing the programmer a powerful cleanup tool. Thoughts? -- The Villagers are Online! http://villagersonline.com .[ (the fox.(quick,brown)) jumped.over(the dog.lazy) ] .[ (a version.of(English).(precise.more)) is(possible) ] ?[ you want.to(help(develop(it))) ] Nov 12 2001
Walter wrote:It is a great idea, but it has implementation problems. The trouble is: 1) it is expensive to scan for references - almost as expensive as doing a full garbage collection run. 2) sometimes references are ambiguous, and it would be an error to raise an exception based on that Nov 13 2001
|