Re: OutOfMemoryError with Proxy
Armin Waibel <[email protected]>
| Newsgroups | gmane.comp.jakarta.ojb.user |
|---|---|
| Message-ID | <[email protected]> |
mananthakris wrote:
> Sorry i checked changing the method to what was suggested on the
> findByPrimarykey page, but the broker class does not seem to have that
> method in the version we use.
yep, this was introduced in a higher version of OJB.
>
> This is the code we are currently using for findByPrimarykey
> String[] keyArray = {key};
> Identity id = new Identity(null,ojbClass,keyArray);
> QueryByIdentity q = QueryFactory.newQuery(id);
> broker = //get it from current odmg transaction
> data = broker.getObjectByQuery(q);
> return data
>
> I could change data to use broker.getObjectByIdentity(id). Will that help?
Maybe. With
String[] keyArray = {key};
Identity id = new Identity(null,ojbClass,keyArray);
broker = //get it from current odmg transaction
data = broker.getObjectByIdentity(id);
OJB will definitely first lookup the cache for the specified object
before a DB-query will be performed.
> It
> does not look like the page on OJB tutorial that creates an Identity with
> only one parameter. We use VARCHAR Ids in our system.
You can create Identity objects with single or compounded PK's (All
common data types are supported (long, Long, String, Date, ....)). It's
only mandatory that all PK fields of the class defined in the repository
mapping file are included when creating the Identity object.
regards,
Armin
>
>
> mananthakris wrote:
>> Thanks for the quick response.We are using OJB1.0rc4. yes we can use
>> getObjectByIdentity. But the stack trace of the error shows that
>> getObjectByQuery is internally calling getObjectByIdentity,so did not
>> think this would help. How can we find how many objects are materialized
>> at a given time?
>> Here since it is byPrimarykey i am assuming at this point of time it is
>> trying to materialize only one object or its all related objects too.
>>
>> Also what does that the stack trace mean by saying that
>> getObjectByIdentity calls getReferencedObject and
>> persistenceBrokerImpl.retrieveCollections (does it try to get all related
>> objects if an object is requested?)
>>
>> Attached is the OJB.properties file and our repository file
>>
>>
>> Armin Waibel wrote:
>>> Hi,
>>>
>>> could you post the OJB.properties and jdbc-connection-descriptor too?
>>> This would help to find problematic settings.
>>> Which version of OJB do you use?
>>>
>>> mananthakris wrote:
>>>> Hi,
>>>> We are using OJB with Jboss,Mysql on linux.
>>>> We have implemented all we could as suggested by OJB performance
>>>> tutorial.
>>>> We are using Proxies,default cache,PB-api,odmg transaction,but we can't
>>>> use
>>>> getIteratorByQuery because the results are processed after the
>>>> transaction
>>>> is closed. We are facing outofmemory error in two places always. One
>>>> while
>>>> materializing subject from proxy and two using getObjectByQuery for
>>>> finding
>>>> an object by primarykey.
>>> Isn't it possible to lookup the object by Identity instead of using a
>>> query?
>>> http://db.apache.org/ojb/docu/tutorials/pb-tutorial.html#Find+object+by+primary+key
>>>
>>>
>>>> It happens only if a lot of users around 200 are
>>>> using the system.
>>> How many objects are materialized?
>>>
>>> regards,
>>> Armin
>>>
>>>> We have two tier systems with jboss running on a linux
>>>> machine with 4GB ram and we have also finetuned jvm options that has
>>>> reduced
>>>> frequency of OutOfMemoryError (we use -Xms768M -Xmx768M
>>>> -XX:NewSize=256M)
>>>> Any suggestions are appreciated? Should we be looking at mysql
>>>> performance,any good tools for profiling ojb?
>>>> Here is the stack trace of two errors
>>>> 1)java.lang.OutOfMemoryError
>>>> rethrown as
>>>> org.apache.ojb.broker.PersistenceBrokerException
>>>> at
>>>> org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectionByQuery(Unknown
>>>> Source)
>>>> at
>>>> org.apache.ojb.broker.core.PersistenceBrokerImpl.retrieveCollection(Unknown
>>>> Source)
>>>> at
>>>> org.apache.ojb.broker.core.PersistenceBrokerImpl.retrieveCollections(Unknown
>>>> Source)
>>>> at
>>>> org.apache.ojb.broker.core.PersistenceBrokerImpl.getDBObject(Unknown
>>>> Source)
>>>> at
>>>> org.apache.ojb.broker.core.PersistenceBrokerImpl.getExtentDBObject(Unknown
>>>> Source)
>>>> at
>>>> org.apache.ojb.broker.core.PersistenceBrokerImpl.getDBObject(Unknown
>>>> Source)
>>>> at
>>>> org.apache.ojb.broker.core.PersistenceBrokerImpl.getObjectByIdentity(Unknown
>>>> Source)
>>>> at
>>>> org.apache.ojb.broker.core.PersistenceBrokerImpl.getReferencedObject(Unknown
>>>> Source)
>>>> at
>>>> org.apache.ojb.broker.core.PersistenceBrokerImpl.retrieveReference(Unknown
>>>> Source)
>>>> at
>>>> org.apache.ojb.broker.core.PersistenceBrokerImpl.retrieveReferences(Unknown
>>>> Source)
>>>> at
>>>> org.apache.ojb.broker.core.PersistenceBrokerImpl.getDBObject(Unknown
>>>> Source)
>>>> at
>>>> org.apache.ojb.broker.core.PersistenceBrokerImpl.getObjectByIdentity(Unknown
>>>> Source)
>>>> at
>>>> org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByIdentity(Unknown
>>>> Source)
>>>> at
>>>> org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByIdentity(Unknown
>>>> Source)
>>>> at
>>>> org.apache.ojb.broker.accesslayer.IndirectionHandler.materializeSubject(Unknown
>>>> Source)
>>>> at
>>>> org.apache.ojb.broker.accesslayer.IndirectionHandler.getRealSubject(Unknown
>>>> Source)
>>>> at org.apache.ojb.broker.VirtualProxy.getRealSubject(Unknown
>>>> Source)
>>>> at
>>>> com.tk20.bo.BaseServerObjectProxy.realSubject(BaseServerObjectProxy.java:46)
>>>> at
>>>> com.tk20.bo.BaseServerObjectProxy.getRelatedObjects(BaseServerObjectProxy.java:334)
>>>> at
>>>> com.tk20.ejb.api.query.QueryMgrEJB.getList(QueryMgrEJB.java:83)
>>>>
>>>> 2)java.lang.OutOfMemoryError
>>>> rethrown as
>>>> org.apache.ojb.broker.PersistenceBrokerException
>>>> at
>>>> org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectionByQuery(Unknown
>>>> Source)
>>>> at
>>>> org.apache.ojb.broker.core.PersistenceBrokerImpl.retrieveCollection(Unknown
>>>> Source)
>>>> at
>>>> org.apache.ojb.broker.core.PersistenceBrokerImpl.retrieveCollections(Unknown
>>>> Source)
>>>> at
>>>> org.apache.ojb.broker.core.PersistenceBrokerImpl.getDBObject(Unknown
>>>> Source)
>>>> at
>>>> org.apache.ojb.broker.core.PersistenceBrokerImpl.getExtentDBObject(Unknown
>>>> Source)
>>>> at
>>>> org.apache.ojb.broker.core.PersistenceBrokerImpl.getDBObject(Unknown
>>>> Source)
>>>> at
>>>> org.apache.ojb.broker.core.PersistenceBrokerImpl.getObjectByIdentity(Unknown
>>>> Source)
>>>> at
>>>> org.apache.ojb.broker.core.PersistenceBrokerImpl.getReferencedObject(Unknown
>>>> Source)
>>>> at
>>>> org.apache.ojb.broker.core.PersistenceBrokerImpl.retrieveReference(Unknown
>>>> Source)
>>>> at
>>>> org.apache.ojb.broker.core.PersistenceBrokerImpl.retrieveReferences(Unknown
>>>> Source)
>>>> at
>>>> org.apache.ojb.broker.core.PersistenceBrokerImpl.getDBObject(Unknown
>>>> Source)
>>>> at
>>>> org.apache.ojb.broker.core.PersistenceBrokerImpl.getExtentDBObject(Unknown
>>>> Source)
>>>> at
>>>> org.apache.ojb.broker.core.PersistenceBrokerImpl.getDBObject(Unknown
>>>> Source)
>>>> at
>>>> org.apache.ojb.broker.core.PersistenceBrokerImpl.getObjectByIdentity(Unknown
>>>> Source)
>>>> at
>>>> org.apache.ojb.broker.core.PersistenceBrokerImpl.getReferencedObject(Unknown
>>>> Source)
>>>> at
>>>> org.apache.ojb.broker.core.PersistenceBrokerImpl.retrieveReference(Unknown
>>>> Source)
>>>> at
>>>> org.apache.ojb.broker.core.PersistenceBrokerImpl.retrieveReferences(Unknown
>>>> Source)
>>>> at
>>>> org.apache.ojb.broker.core.PersistenceBrokerImpl.getDBObject(Unknown
>>>> Source)
>>>> at
>>>> org.apache.ojb.broker.core.PersistenceBrokerImpl.getExtentDBObject(Unknown
>>>> Source)
>>>> at
>>>> org.apache.ojb.broker.core.PersistenceBrokerImpl.getDBObject(Unknown
>>>> Source)
>>>> at
>>>> org.apache.ojb.broker.core.PersistenceBrokerImpl.getObjectByIdentity(Unknown
>>>> Source)
>>>> at
>>>> org.apache.ojb.broker.core.PersistenceBrokerImpl.getReferencedObject(Unknown
>>>> Source)
>>>> at
>>>> org.apache.ojb.broker.core.PersistenceBrokerImpl.retrieveReference(Unknown
>>>> Source)
>>>> at
>>>> org.apache.ojb.broker.core.PersistenceBrokerImpl.retrieveReferences(Unknown
>>>> Source)
>>>> at
>>>> org.apache.ojb.broker.core.PersistenceBrokerImpl.getDBObject(Unknown
>>>> Source)
>>>> at
>>>> org.apache.ojb.broker.core.PersistenceBrokerImpl.getObjectByIdentity(Unknown
>>>> Source)
>>>> at
>>>> org.apache.ojb.broker.core.PersistenceBrokerImpl.getObjectByQuery(Unknown
>>>> Source)
>>>> at
>>>> org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByQuery(Unknown
>>>> Source)
>>>> at
>>>> org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByQuery(Unknown
>>>> Source)
>>>> at
>>>> com.tk20.ejb.api.BaseServiceEJB.findByPrimaryKey(BaseServiceEJB.java:189)
>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [email protected]
>>> For additional commands, e-mail: [email protected]
>>>
>>>
>>>
>> http://www.nabble.com/file/4504/OJB.properties OJB.properties
>> http://www.nabble.com/file/4505/repository.xml repository.xml
>> http://www.nabble.com/file/4506/repository_user.xml repository_user.xml
>> http://www.nabble.com/file/4507/repository_internal.xml
>> repository_internal.xml
>>
>