[hibernate-dev] Memory consumption
Scott Marlow
smarlow at redhat.com
Thu May 10 19:09:48 EDT 2012
On 05/10/2012 06:11 PM, Andrej Golovnin wrote:
> Hi all,
>
> we use a EAR file which contains a WAR file and a JAR file with
> all our entity classes. And we have a single persistent unit.
> We don't use JavaBean validation, nor we use Hibernate Envers.
>
> Here is a small list with numbers for our application(not sure
> if it would help to understand/solve the problem):
>
> Used Access type: FIELD
> Number of tables: 1299
> Number of columns: 18045
> Number of classes with @MappedSuperclass: 45
> Number of classes with @Entity (including abstract classes): 970
> Number of classes with @Embeddable: 233
> Number of classes with @Inheritance: 13
>
> The screen shot with JBoss 4 is made from memory snapshot
> of a running production system. The screen shot with JBoss 7 is made
> from memory snapshot right after startup (no application code were executed,
> Lucene indexes are empty).
>
> About "nearly twice as much memory":
> The situation is following. When I start JBoss 4 with our application
> and look at the memory consumption, I see that ca. 300MB of heap
> are already allocated. The most memory is consumed by objects
> related to the "org.hibernate"-package and by objects related
> to JPA support from the "org.jboss"-package. When I start JBoss 7
> with our application, I see now more than 600MB of the used heap.
> And the most memory is again consumed by objects related to
> ORM+Search+JPA.
>
> After updating JBoss 7 to use the Hibernate Validator 4.3.0 and
> adding<property name="javax.persistence.validation.mode" value="NONE"/>
> to our persistence.xml file I was able to reduce memory consumption
> of SerializableValidatorFactory from ca. 90MB to ca. 256KB. :-)
It sounds like adding <property name="javax.persistence.validation.mode"
value="NONE"/>, is responsible for the memory savings, more than using
Hibernate Validator 4.3.0. If not, it would be helpful for us to know that.
I wouldn't expect much more savings than that (with validation mode set
to NONE, we won't pass a validator instance into the session factory).
If your using MAT, I would drill into the "outgoing" references from the
org.hibernate.internal.SessionFactoryImpl and produce more pictures of
the objects consuming the larger part of that memory.
Also, it might be helpful for us to see your persistence.xml.
> What I was not able to do, is to avoid loading of Hibernate Validator
> and Hibernate Envers at all as we don't use them.
>
> It's also unclear to me why Configuration, JavaReflectionManager,
> FullTextIndexEventListener don't show up. If I use MAT, I see that
> the size of JavaReflectionManager is nearly identical in both cases.
>
> I need more time to investigate the differences between the old and
> new versions. But one thing you can change already:
> Configuration#seconPasses should be recreated
> when Configuration#secondPassCompile() finishes or consider using
> LinkedList. In my case the #seconPasses has the size of 0. But the backend
> array has the length of ca. 27000. With this change you will not save a lot of
> memory, but I welcome every single byte I can get. :-)
>
> Best regards
> Andrej Golovnin
> _______________________________________________
> hibernate-dev mailing list
> hibernate-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hibernate-dev
More information about the hibernate-dev
mailing list