I'm using JavaEE7, hibernate-jpa2.1
My project have too many entity ( approximately 2000 entity)
If it only have 100 objects entity, it startup normal.
But now I've added all my business entity classes (2000) and I get a pergem space error.
2016-12-29T11:40:36.903+0700|Severe: Exception in thread "DynamicReloader"
2016-12-29T11:40:36.904+0700|Severe: java.lang.OutOfMemoryError: GC overhead limit exceeded
2016-12-29T11:40:37.899+0700|Severe: Exception in thread "AutoDeployer"
2016-12-29T11:40:37.900+0700|Severe: java.lang.OutOfMemoryError: GC overhead limit exceeded
I've improve jvm memory parameters but now my application is very slow during the start-up.
So, I would know if there are some option to load this entities faster ?
Thank in advance
This is example entity
@Entity
@Table(name = "TBL_USER")
@NamedQueries({
@NamedQuery(name = "TblUserO.findAll", query = "SELECT t FROM TblUserO t")
})
public class TblUserO implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "USER_ID", unique = true, nullable = false, precision = 11)
private Long userId;
persistence.xml
<persistence-unit name="c1spostgre1" transaction-type="JTA">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<jta-data-source>jdbc/__PSG1</jta-data-source>
<!-- Named JPQL queries per entity, but any other organization is possible -->
<properties>
<property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.SunOneJtaPlatform"/>
<property name="hibernate.enable_lazy_load_no_trans" value="true"/>
<!-- <property name="hibernate.archive.autodetection" value="class" /> -->
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="true" />
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQL92Dialect" />
<property name="hibernate.jdbc.batch_size" value="20" />
<property name="hibernate.order_updates" value="true"/>
<property name="hibernate.order_inserts" value="true"/>
</properties>
</persistence-unit>
<persistence-unit name="c1spostgre2" transaction-type="JTA">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<jta-data-source>jdbc/__PSG2</jta-data-source>
<properties>
<property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.SunOneJtaPlatform"/>
<property name="hibernate.enable_lazy_load_no_trans" value="true"/>
<!-- <property name="hibernate.archive.autodetection" value="class" /> -->
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="true" />
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQL92Dialect" />
<property name="hibernate.jdbc.batch_size" value="20" />
<property name="hibernate.order_updates" value="true"/>
<property name="hibernate.order_inserts" value="true"/>
</properties>
</persistence-unit>
You have increased the heap memory (not permgen) enough so that your app can now start, but with so much needing to be loaded into memory you are almost certainly doing lots of garbage collection while all this gets loaded, which will cause the slowdown. It sounds like you need to do extensive performance tuning of your app, but that is very far outside the scope of a StackOverflow question.