Hi folks,

My first forrey into Perl objects sees me trying to model a railway.  I've got 
a hash of named blocks of track, which is added to when I create a new block 
object.

My problem is one of destroying a block (object), making sure that I have no 
memory leakage.

I create a new track block such:

my $T1=Trainset->track('T1','Block');

This also created $Trainset::_BLOCKS{T1} which references the object.

My problem is how can I destroy the object when I no longer want it?

If I call

$T1=$T1->delete;

Then the object is destroyed (display in DESTROY shows this).  However, if I 
simply call

$T1->delete;

The object isn't destroyed because even though the ref in %_BLOCKS is deleted, 
the ref in $T1 is still there.  Is there and way to ensure that the object is 
destroyed - i.e. force the refcount to zero?

The only solution I've come up with is to explicitly call DESTROY from within 
the delete function, and within DESTROY empty the hash. Is this sufficient, 
or will this still tie up memory?  Is there a better way?

-- 
Gary Stainburn
 
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000     


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to