0

Here is the exception Details : -

java.lang.OutOfMemoryError: Java heap space
        at com.mysql.jdbc.Buffer.<init>(Buffer.java:57)
        at com.mysql.jdbc.MysqlIO.nextRow(MysqlIO.java:2087)
        at com.mysql.jdbc.MysqlIO.readSingleRowSet(MysqlIO.java:3549)
        at com.mysql.jdbc.MysqlIO.getResultSet(MysqlIO.java:489)
        at com.mysql.jdbc.MysqlIO.readResultsForQueryOrUpdate(MysqlIO.java:3240)
        at com.mysql.jdbc.MysqlIO.readAllResults(MysqlIO.java:2411)
        at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2834)
        at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2838)
        at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2082)
        at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2212)
        at sun.reflect.GeneratedMethodAccessor99.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:122)
        at org.hibernate.engine.jdbc.internal.proxy.AbstractProxyHandler.invoke(AbstractProxyHandler.java:81)
        at com.sun.proxy.$Proxy168.executeQuery(Unknown Source)
        at org.hibernate.loader.Loader.getResultSet(Loader.java:1978)
        at org.hibernate.loader.Loader.doQuery(Loader.java:829)
        at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:289)
        at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
        at org.hibernate.loader.Loader.loadCollectionSubselect(Loader.java:2242)
        at org.hibernate.loader.collection.SubselectOneToManyLoader.initialize(SubselectOneToManyLoader.java:77)
        at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:622)
        at org.hibernate.event.internal.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:82)
        at org.hibernate.internal.SessionImpl.initializeCollection(SessionImpl.java:1606)
        at org.hibernate.collection.internal.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:379)
        at org.hibernate.collection.internal.AbstractPersistentCollection.read(AbstractPersistentCollection.java:112)
        at org.hibernate.collection.internal.AbstractPersistentCollection.readSize(AbstractPersistentCollection.java:137)
        at org.hibernate.collection.internal.PersistentBag.isEmpty(PersistentBag.java:249)
        at com.vms.business.SupplierSearchService.fetchTopFiveAssociatedSuppliersList(SupplierSearchService.java:369)
        at com.vms.business.SupplierSearchService$$FastClassBySpringCGLIB$$c4e470d2.invoke(<generated>)
        at org.springframework.cglib.proxy.Meth

odProxy.invoke(MethodProxy.java:204)

Here is the Hibernate Query where I am getting exception :- **Note :- ** The same query works well when I use My SQL 5.1 with same data. One More thing when i use My SQL 5.7.23 RDS connection the whole application go slow. The new RDS has 4 time higher configuration from the 5.1 My SQL RDS service but still giving error.

Here is the query : -

Session session = em.unwrap(Session.class);
Criteria criteria = session.createCriteria(Orgassociation.class, "orgassociation");
criteria.createAlias("orgassociation.organization", "associatedOrgs");

Criteria userCriteria = session.createCriteria(User.class, "user");
userCriteria.add(Restrictions.eq("user.userId", userId));
User user = (User) userCriteria.uniqueResult();
criteria.add(Restrictions.eq("orgassociation.organization1.organizationId",
user.getOrganization().getOrganizationId()));
criteria.add(Restrictions.eq("associatedOrgs.orgType", VMS_CONSTANTS.DB_CONSTANTS.EMPLOYER_AND_SUPPLIER));
criteria.addOrder(Order.desc("orgassociation.orgAssociationId"));
criteria.setMaxResults(5);

@SuppressWarnings("unchecked")
List<Orgassociation> orgList = criteria.list();

1 Answer 1

0

You would need to attach a Java profiler (VisualVM) or Your kit and anaylse your heap to know which objects are actually causing this. It is very likely that some client sdk contract is broken resulting in a lot of java objects lying around without GC.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.