in reply to Re: Re: Can you determine the number of References to a value?
in thread Can you determine the number of References to a value?
Yes, deleting your reference when the count goes to 1 makes sense in some situations. A more efficient way to accomplish this (and more general since it allows two or more different chunks of software to do the same trick to the same data) is called a "weak reference" which is available in Perl 5.6 and later.
A weak reference is just like an ordinary Perl reference except that it isn't included in the reference count of the thing referred to. This means that once all references to a particular piece of data are weak, the piece of data is freed and all the weak references are set to undef.
So you just have to check your weak references to make sure they haven't become undef before you use them. See WeakRef.
- tye (but my friends call me "Tye")
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (tye)Re: Can you determine the number of References to a value?
by shotgunefx (Parson) on Sep 13, 2001 at 13:20 UTC |