Maintaining a pool of DAO Class instances vs doing new operator
- by Fazal
we have been trying to benchmark our application performance in multiple way for sometime now.
I always believed that object creation in java using Class.newInstance() was not slow (at least after 1.4 version of java). But we anyways did a test to use newInstance method vs mainitain an object pool of 1000 objects. We did about 200K iterations of loading data from DB using JDBC and populating these objects.
I was amazed (even shocked) to see that newInstance code compared to object pool code was almost 10 times slower.
These objects represent tables with about 50 fields and all string type.
Can someone share there thoughts on this issue as now I am more confused if object pooling of atleast some DAO instances is a better option. The pool size as I see right now should be large enough to meet size of average requests.
There is a flip side as my memory footprint will go up but I am beginning to wonder if this kind of idea makes sense atleast for some of the DAO entities representing tables of about 50 or more columns
Please share your ideas and let me know if this has been tried by someone or am I missing some point here