Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2010-08

refcounting in fcl-passrc

10 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Marco van de Voort

I still get errors on deallocation in fpdoc from time to time.

The most recent one is related to TPasFunctionType.

I searched a bit, and since the type is not used that much, I suspect TPasTreeContainer.CreateFunctionType.

Since in both cases the resultparent is an already used reference, shouldn't it be increfed ?

Reply by email

Michael Van Canneyt
to Marco van de Voort
Marco van de Voort wrote 10 lines
I still get errors on deallocation in fpdoc from time to time. The most recent one is related to TPasFunctionType. I searched a bit, and since the type is not used that much, I suspect TPasTreeContainer.CreateFunctionType. Since in both cases the resultparent is an already used reference, shouldn't it be increfed ?

Probably.

Till you told me, I wasn't even aware that there was a refcounting mechanism. I see no reason why there should be one, so I'd be in favour of removing it alltogether.

Michael.

Reply by email

Marco van de Voort
to Michael Van Canneyt

In our previous episode, Michael Van Canneyt said:

Show quoted text 8 lines
> Since in both cases the resultparent is an already used reference, shouldn't > it be increfed ? Probably. Till you told me, I wasn't even aware that there was a refcounting mechanism. I see no reason why there should be one, so I'd be in favour of removing it alltogether.

Then you need some global list to add them to. (to be able to deallocate). It might be the various TPasModule sections already double as something like this, but that has to be validated.

Dmitry, what do you think?

Reply by email

Michael Van Canneyt
to Marco van de Voort
Marco van de Voort wrote 11 lines
In our previous episode, Michael Van Canneyt said: >> Since in both cases the resultparent is an already used reference, shouldn't >> it be increfed ? > > Probably. > > Till you told me, I wasn't even aware that there was a refcounting mechanism. > I see no reason why there should be one, so I'd be in favour of removing it > alltogether. Then you need some global list to add them to. (to be able to deallocate).

Why ?

It might be the various TPasModule sections already double as something like this, but that has to be validated.

Each element should deallocate it's "children".
Since an element tree is always a strict tree, this is unambiguous. Refcounting is not 'm not in favour of a global list and a 'garbage collection' style of memory management. It makes manipulating the tree a pain.

This will take some reworking, apparently (each destructor must be filled with code to deallocate children). For the time being, try the incref.

Michael.

Reply by email

Marco van de Voort
to Michael Van Canneyt

In our previous episode, Michael Van Canneyt said:

Show quoted text 6 lines
> It might be the various TPasModule sections already double as something like > this, but that has to be validated. Each element should deallocate it's "children". Since an element tree is always a strict tree, this is unambiguous.

I don't really see this, since in many of passrc's routines objects are created if they cannot be found? This means that there is a chance that such object has no other refernece than the one returned. E.g. when searched for a reference that is not strictly a child like ancestor.

That would need to be refactored too then.

Reply by email

dmitry boyarintsev
to Michael Van Canneyt
Michael Van Canneyt wrote
And why do you want this ? refcounting is always a pain, and should be avoided when possible.

Rewriting code might produce even more bugs. I prefer to make as less changes as possible.

thanks,
dmitry

Reply by email

Michael Van Canneyt
to dmitry boyarintsev
dmitry boyarintsev wrote 7 lines
On Sun, Aug 22, 2010 at 11:32 AM, Michael Van Canneyt wrote: > And why do you want this ? refcounting is always a pain, and should be > avoided when possible. Rewriting code might produce even more bugs. I prefer to make as less changes as possible.

We would not be rewriting the parser; merely the TPasElement nodes.

I'll do it myself, this is not a problem.

Michael.

Reply by email

dmitry boyarintsev
to Michael Van Canneyt
Michael Van Canneyt wrote
We would not be rewriting the parser; merely the TPasElement nodes. I'll do it myself, this is not a problem.

Ok then. No more refcounting.

So TPasExpr classes doesn't require changes. Currently they free sub expressions instead of releasing them.

thanks,
dmitry

Reply by email