Hi list!

I seek advice from those wiser than I...

I am writing a service that exposes a method looking a little like the
following:

List<Stuff> doManyThings(int howMany)
  {
  List<Stuff> l = new ArrayList<Stuff>(howMany);
  
  for (int i = 0; i < howMany; i ++)
    l.add(new Stuff(i));

  return l;
  }

Since the value for 'howMany' may work out to be very large, I am worried
about performance.

(I am leaving aside the overheads implicit with XML at the moment...may bite
me later, of course)

I can create a pool of Stuff instances (using commons pool for example) and
retrieve from the pool, rather than creating myriad new Stuff instances all
the time...this should be beneficial.

The question is: since the list of Stuff instances is returned to the
'container' and never seen by my code again, how/when do I release instances
back into the pool?

Can I write an interceptor for this? How? My gut feel is that this is/should
be a faq but I can't find anything!

Is there a more effective approach than what I am taking? Perhaps I should
create the XML directly, rather than rely on CXF's marshalling...but I'd
rather not be forced to do this in a way that changes the existing method
signature (by having to return an org.w3c.dom.Document, say)

Cheers,

BOB

Reply via email to