Jon Perryman wrote:

<begin extract>
This is where elements on your chain are no longer needed. Peter
recommends not freeing the element. Instead, you should use a queue of
free elements that you reuse when you need a new , , ,
</end extract>

and I have two comments.

First, 'queue of free elements'  need not be taken literally.  These
elements can and should be managed as a pool, implemented as a LIFO
list not because LIFO sequencing is itself important but because it is
simpler than alternatives to it.

Second, such lists and their associated pools are better managed using
a primary element-allocation quantity p and a secondary
element-allocation quantity s, with s >= p.

When processing is initialized p elements are added to the pool.
Thereafter an element is always removed from the pool when one is
needed and returned to the pool when it is no longer needed.

The secondary allocation s figures in processing in just one way.  If
the pool is found to be empty when an attempt is made to remove an
element from it s elements are added to the pool.

A further operation is usually appropriate.  Testing to ensure that
the current pool-element count c is less than s when an element is to
be returned to the pool, and freeing its storage instead iff c = s
ensures that surges of acrtivity do not result in the accumulation of
excessive numbers of elements in the pool.

This scheme has the merit that it is 0c4-proof.  No freed storage is
reused.  It is also simple, fast and tunable.


John Gilmore, Ashland, MA 01721 - USA

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to