[fpc-pascal] methods of an object to create others objects

Andrew Brunner andrew.t.brunner at gmail.com
Wed Jul 7 00:14:32 CEST 2010


On Tue, Jul 6, 2010 at 5:09 PM, Graeme Geldenhuys
<graemeg.lists at gmail.com> wrote:
> Even with a try..except, if you call MyObj.Free and it causes an
> exception, you are screwed either way and it will always cause a
> memory leak. Best is no notify the user some how, or crash out of the
> program, or fire the programmer for not writing enough unit tests. :)

No, if the nesting is done properly you could guarantee that Obj2.Free
would be called even if Obj1.Free failed with some exception.  And
further, nested exception handling offers safeguarding against such
memory leaks during destruction if done properly.  To me this is the
difference between good software and great software... How well it
handles exceptions.



More information about the fpc-pascal mailing list