gmpassos has asked for the wisdom of the Perl Monks concerning the following question:
But now I have a problem, how to know if a reference was cleaned/destroied? I need to know that to automatically remove references/objects from the HASH and free 100% of the memory that should be free after clean that variable.
Note that the behavior of a SCALAR that holds a reference after have it cleaned is strange:
So, there is a better way to know if the reference is dead, some flag, internal command different than SvREFCNT()?$hash_nor_ref->{ref} = {} ; #will have REFCNT = 0 on clean $hash_nor_ref->{ref} = [] ; #will have REFCNT = 0 on clean $hash_nor_ref->{ref} = \'' ; #will have REFCNT = 1 on clean $hash_nor_ref->{ref} = bless({}) ; #before destroy have a reference to + a blessed HASH, after destroy it will have a reference to a SCALAR, +with REFCNT = 1.
If is not possible to have a better way to know that I will need to map the behaviors of dead references and work over that, but I don't think that this will work very well.
By the way, you can take a look in what was already done: Hash-NoRef-0.01. (Use it as a beta version)
Graciliano M. P.
"Creativity is the expression of the liberty".
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Playing with the Reference Count of variables (to create a POOL of objects wihtout mess with DESTROY).
by perrin (Chancellor) on Apr 16, 2004 at 21:21 UTC | |
|
Re: Playing with the Reference Count of variables (to create a POOL of objects wihtout mess with DESTROY).
by Steve_p (Priest) on Apr 16, 2004 at 21:04 UTC | |
|
Re: Playing with the Reference Count of variables (to create a POOL of objects wihtout mess with DESTROY).
by BUU (Prior) on Apr 16, 2004 at 21:29 UTC | |
by adrianh (Chancellor) on Apr 16, 2004 at 21:46 UTC |