[fpc-devel] Need patch for bugs : 0011503 / 0009472

Boian Mitov mitov at mitov.com
Thu Jun 19 15:10:23 CEST 2008

This is not very precise. You are referring to garbage collection in 
general. Reference counting as it used to be defined in the original COM 
specification for DLL and statically linked objects specifically states that 
the object will be destroyed as soon as the last reference to it is lost. 
The non deterministic garbage collector is the exact reason we don't have 
stable Java programs, and they al tend to leak, and crash the systems. There 
is no Garbage collection per say for resources, and there is no function 
enclosement either. .NET has number of ugly language extensions "patches" to 
work around that in C#, but this is a whole different story. To be able to 
work with resources we have to have a tight control over their lifespan. 
otherwise we are in a grave danger of crashes. We can surely revert to the 
old days of doing that with functional programming, as Java developers tend 
to do, but that has all the disadvantages and dangers of functional 
programming. OOP is supposed to assist us in writing safe code, not endanger 

  With best regards,
    Boian Mitov

Mitov Software

----- Original Message ----- 
From: "Jonas Maebe" <jonas.maebe at elis.ugent.be>
To: "FPC developers' list" <fpc-devel at lists.freepascal.org>
Sent: Thursday, June 19, 2008 5:55 AM
Subject: Re: [fpc-devel] Need patch for bugs : 0011503 / 0009472

> Reference counting only guarantees that
> a) an instance will not be freed as long as any references to it exist
> b) an instance will be freed automatically after the last reference 
> disappears
> It does not guarantee/define
> a) at which point in the code exactly an instance will be freed
> b) the actual mechanism used for reclaiming the memory (a simple free 
> when the reference count hits zero, mark and sweep, ...)
> It is therefore not a substitute for managing other kinds of resources 
> which require predictable freeing points. The above example is 
> conceptually identical to several of the examples given in the  comments 
> to http://bugs.freepascal.org/view.php?id=9472
> It's similar to how you cannot use the Finalize method in Java to  perform 
> resource management, because it will only be called when the  garbage 
> collector reaps your instance and not necessarily immediately  when the 
> last reference to an instance is gone.
> Jonas
> _______________________________________________
> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-devel 

More information about the fpc-devel mailing list