in reply to Possible Memory Usage Issues
That's a bit hard to say without seeing a bit more of your code, including all of the "constants" that you're using as array indexes. If any one of those constants is a large number, you're going to be wasting lots of space in each Node and Leaf.
You could do away with $cont::getType entirely. You needn't hang on to "Node" or "Leaf" in each object. Instead, use ref() to check which type of thing you're looking at, or add an isLeaf member function to each object, returning 0 or 1 as appropriate.
Also, rather than hanging an anonymous array off of [$node::leaves], you could save a bit of space by keeping a separate [$node::left] and [$node::right]. The overhead for a slot within an array is lower than the overhead for an array, even if empty.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Possible Memory Usage Issues
by abitkin (Monk) on Aug 07, 2002 at 13:50 UTC | |
by dws (Chancellor) on Aug 07, 2002 at 15:50 UTC | |
by abitkin (Monk) on Aug 07, 2002 at 16:45 UTC |