You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by Vorác Jirí <Vo...@webcom.cz> on 2001/10/01 12:29:15 UTC

Do I need object pool ?

Hi,

I have class providing one method (not synchronized).
Method does not change any class variables, it only reads them.
Class variables are initialized in constructor, so this instance
has fixed configuration.

My question is: Can I call these methods from more
	threads concurrently or should I use object pool for every
configuration?
in other words: Could there be problem, if I use only one instance for one
configuration?

Maybe you can explain me what is advantage or necessity using object
pooling.

Thanks in advance

Jirka
---
Odchozí zpráva neobsahuje viry.
Zkontrolováno antivirovým systémem AVG (http://www.grisoft.cz).
Verze: 6.0.281 / Virová báze: 149 - datum vydání: 18.9. 2001


---------------------------------------------------------------------
To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: avalon-dev-help@jakarta.apache.org


Re: Do I need object pool ?

Posted by Peter Donald <do...@apache.org>.
On Mon, 1 Oct 2001 20:29, Vorác Jirí wrote:
> Hi,
>
> I have class providing one method (not synchronized).
> Method does not change any class variables, it only reads them.
> Class variables are initialized in constructor, so this instance
> has fixed configuration.
>
> My question is: Can I call these methods from more
> 	threads concurrently or should I use object pool for every
> configuration?
> in other words: Could there be problem, if I use only one instance for one
> configuration?

>From the sounds of things it should be fine. This is based on the assumption 
that the method only reads values that are constructed prior to method call. 
If the there is no writes *ever* (even from other methods) then you should be 
fine.

> Maybe you can explain me what is advantage or necessity using object
> pooling.

If you are creating and then throwing away lots of objects at runtime then 
the performance penalty of creation and then garbage collection of objects 
can be high. Especially when these resources attach to heavy/native resources 
(like network connections, threads, db connections etc).

Object pools minimize this cost by trying to keep a relatively constant set 
of objects in memory. This means you don't pay creation + garbage collection 
costs (instead it can use a little more memory at times when object is not in 
use).

-- 
Cheers,

Pete

---------------------------------
I think not; therefore I ain't...
---------------------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: avalon-dev-help@jakarta.apache.org