in reply to chaining method calls
Consider this code:
use HugeObject; my $result = 0; { my $object = HugeObject->new(); $result = $object->get_even_bigger(); $object = undef; } # Phew, should free up memory now. if ($result) { # code here }
As the object was created inside the {} it should go out of scope and the memory should be cleared - a good thing. However as object returns a reference to itself it is not cleared, and stays in memory.
If the object had just returned true or false this would not be a problem.
This may not be a problem if you read the docs for HugeObject but why add the compication for some slightly shorter code?
--tidiness is the memory loss of environmental mnemonics
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: chaining method calls
by adrianh (Chancellor) on Jun 12, 2003 at 10:16 UTC |