[Lazarus] Log4D weirdness

Marcos Douglas md at delfire.net
Thu Jan 1 18:59:18 CET 2015


On Thu, Jan 1, 2015 at 2:39 PM, Marco van de Voort <marcov at stack.nl> wrote:
> On Thu, Jan 01, 2015 at 01:04:22AM -0200, Marcos Douglas wrote:
>> >
>> > 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.
>
> Ah, you mean that. I didn't consider that an interface problem, since the
> ref is in an object. (whose aren't refcounted). IOW by design :-)

If I understood right, you mean it only uses interfaces but not refcount?

>> > 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.
>
> Certainly. It doesn't even try, and as soon as you try to overuse it, it
> breaks down. It is IMHO a designchoice and not a flaw though.
>
>> > 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.
>
> Then why do you write such code ? :-)

I didn't understand. What code, AWS Lib? If yes, well I wrote such
code because I know the workarounds to limit such problems with
interfaces, refcount and circular reference. But is not easy, memleaks
could happen. Unit tests and -gh argument have helping a lot.

>> > 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!
>
> Happy New Year. May 3.0 be all that we hope it will be.

WOW! I can not wait for it!


Marcos Douglas




More information about the Lazarus mailing list