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".
In reply to Playing with the Reference Count of variables (to create a POOL of objects wihtout mess with DESTROY). by gmpassos
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |