hibernate中@Entity的对象对应的表字段非常多的情况
小弟在项目中遇到了内存瓶颈,服务器内存总是溢出,我在后面会列出dump文件的内容,我在猜想hibernate将表对象化成@Entity的对象,如果这个对象的成员变量很多,换言之表的字段很多(200左右),如果调用类似save,query的方法是不是很占用内存?还有几个疑问也请大家帮着解释一下,我只是在猜想:
1 java中对象的成员变量越多,在new的时候是否会占更多的内存?
2 hibernate中在SQLQuery.list()方法和类似findByExample的方法后是否需要调用flush和clear,有些地方说需要调用,否则会有内存的问题,我不确定。
dump:
1.
LeakSize TotalSize Size Analysis Name Address
971389703 971396517 24 Responsible for 971,396,517 bytes (57.8 %) of Java heap org/apache/commons/collections/SequencedHashMap$Entry 0x82b2c5e8
1,258,104,359 (74.86%) [40] 1 java/util/HashMap 0x7f53ffc8
1,258,104,319 (74.86%) [64] 2 array of [Ljava/util/HashMap$Entry; 0x83c2bc88
1,258,104,184 (74.86%) [24] 2 java/util/HashMap$Entry 0x83c2bd40
1,258,104,160 (74.86%) [30] 2 org/springframework/orm/hibernate3/SessionHolder 0x83c2be48
1,258,104,100 (74.86%) [28] 2 java/util/Collections$SynchronizedMap 0x83c2bed8
1,258,104,072 (74.86%) [40] 1 java/util/HashMap 0x83c2bf48
1,258,104,032 (74.86%) [8] 1 array of [Ljava/util/HashMap$Entry; 0x83c2bf70
1,258,104,024 (74.86%) [24] 2 java/util/HashMap$Entry 0x83c2bf88
1,258,104,000 (74.86%) [80] 11 org/hibernate/impl/SessionImpl 0x82b0ee38
1,258,102,913 (74.86%) [78] 13 org/hibernate/engine/StatefulPersistenceContext 0x82b0f308
980,349,426 (58.33%) [17] 2 org/hibernate/util/IdentityMap 0x82b2c110
980,349,405 (58.33%) [24] 2 org/apache/commons/collections/SequencedHashMap 0x82b2c588
971,396,517 (57.8%) [24] 2 org/apache/commons/collections/SequencedHashMap$Entry 0x82b2c5e8
971,396,406 (57.8%) [24] 4 org/apache/commons/collections/SequencedHashMap$Entry 0x7f619578
87 (0%) [24] 4 org/apache/commons/collections/SequencedHashMap$Entry 0xffffffffe5e9b240
2.
LeakSize TotalSize Size Analysis Name Address
277752297 277752297 2097152 277,752,297 bytes (16.53 %) of Java heap is used by 220,347 instances of java/util/HashMap$Entry array of [Ljava/util/HashMap$Entry; 0xb5cbe268
1,258,104,387 (74.86%) [28] 3 java/lang/ThreadLocal$ThreadLocalMap$Entry 0x7ba45208
1,258,104,359 (74.86%) [40] 1 java/util/HashMap 0x7f53ffc8
1,258,104,319 (74.86%) [64] 2 array of [Ljava/util/HashMap$Entry; 0x83c2bc88
1,258,104,184 (74.86%) [24] 2 java/util/HashMap$Entry 0x83c2bd40
1,258,104,160 (74.86%) [30] 2 org/springframework/orm/hibernate3/SessionHolder 0x83c2be48
1,258,104,100 (74.86%) [28] 2 java/util/Collections$SynchronizedMap 0x83c2bed8
1,258,104,072 (74.86%) [40] 1 java/util/HashMap 0x83c2bf48
1,258,104,032 (74.86%) [8] 1 array of [Ljava/util/HashMap$Entry; 0x83c2bf70
1,258,104,024 (74.86%) [24] 2 java/util/HashMap$Entry 0x83c2bf88
1,258,104,000 (74.86%) [80] 11 org/hibernate/impl/SessionImpl 0x82b0ee38
1,258,102,913 (74.86%) [78] 13 org/hibernate/engine/StatefulPersistenceContext 0x82b0f308
980,349,426 (58.33%) [17] 2 org/hibernate/util/IdentityMap 0x82b2c110
277,752,337 (16.53%) [40] 1 java/util/HashMap 0x82b2c0c0
277,752,297 (16.53%) [2,097,152] 220,347 array of [Ljava/util/HashMap$Entry; 0xb5cbe268