[Lazarus] Log4D weirdness

Marcos Douglas md at delfire.net
Thu Jan 1 04:04:22 CET 2015


On Wed, Dec 31, 2014 at 6:56 PM, Marco van de Voort <marcov at stack.nl> wrote:
> On Sun, Dec 28, 2014 at 07:51:25PM -0200, Marcos Douglas wrote:
>> > Delphi. As a first try I remove the "const", in case of unexpected trouble.
>>
>> Delphi and FPC have problems with refcounting -- but I'm referring
>> only interfaces.
>> Circular references is a big problem too.
>
> This is totally new for me. I have used interfaces a lot, and while I had
> trouble from time to time, I haven't really encountered these.

New? What do you mean?
This problem was talked in FPC list and here before.
I use "weak reference". Somethings are not possible to implement
without this "technique".
For example:
https://github.com/mdbs99/AWS/blob/master/src/aws_s3.pas#L166
https://github.com/mdbs99/AWS/blob/master/src/aws_s3.pas#L304

These objects have circular reference and they need weak reference to
keep memory safe.

>> This link could help:
>> http://blog.synopse.info/post/2012/06/18/Circular-reference-and-zeroing-weak-pointers
>
> IMHO wrong. GC also has problems, e.g. when two roots circularly reference
> eachother. The major implementations are somewhat hardened against it, but
> more involved reference counting implementations (like Python) are too.

I know some others approaches have problems, but Delphi/FPC is not perfect too.

> Delphi/FPC reference counting is simple and cheap. The problem is IMHO not
> the implementation, but the fact that people try to abuse it for things it
> wasn't meant for (a holistic automatic memory management solution).

I agree.

> ARC is IMHO no solution but only damage control (by explicitely naming pure
> references). IIRC Python has similar tricks to keep circular detections
> cheap (cycle checking can stop at a weak reference)

Happy New year!

Regards,
Marcos Douglas




More information about the Lazarus mailing list