Re: [OJB-developers] Performance improvements with Identity objects
Brought to you by:
thma
From: Thomas M. <tho...@ho...> - 2002-02-27 13:49:14
|
Hi Florian, Florian Bruckner wrote: > Hi, > > while fixing the referential integrity issue in the ODMG layer I found that > Identity objects are instantiated over and over again. Instantiating objects > is one of the most expensive operations one can do in Java, first it creates > a lot overhead when instantiating such classes, then it adds overhead in the > garbage collector. > You are absolutely right. I have been thinking of a solution for this quite a while, but was afraid of maintaining a huge pool of Identities. > Once an Identity object is created, the chances it will change is very > little. Identities are immutable! > Why not store the Identity object, once it is created? VirtualProxy > and IndirectionHandler already do this, if you create an Identity the > content of the stored Identity is copied. If we added such storing > capabilities for normal objects to a, lets say, IdentityFactory, in most > cases a new instantiation could be avoided. > > If an Identity object is requested from IdentityFactory, it should first > check whether for the given object an Identity exists. If yes in a second > step it should be checked if the key values have changed. IMO we won't need step too as a client app *must not* change PK values! If yes, create a > new Identity (because Identity should be immutable, imho, so they could > still be used in HashMaps), if no just return the already existing object. > Right > Most critical for design and implementation is in my opinion avoiding memory > leaks. But I think this could be handled with WeakReference and friends. > I like your idea very much. It will definitely reduce the OJB overhead. But I think we have to very careful in designing the Identity pool. It should not grow beyond some reasonable limits. If such care is taken this will be an enourmous performance boost! cu, Thomas > Any comments? > > lG, > Florian > > > _______________________________________________ > Objectbridge-developers mailing list > Obj...@li... > https://lists.sourceforge.net/lists/listinfo/objectbridge-developers > > > > |