可以增加java堆中的对象数量是一个指示性的吗?

时间:2013-08-23 16:05:31

标签: java memory-management

下面是我捕获的3个不同堆样本的样本。我知道我的堆大小很小,但是对象的数量有所增加,这代表什么,这也让我担心。我还把泄漏嫌疑人,主要是指我正在做汇总的数据库。有没有办法确认我的汇集没有泄漏?

第一个样本。

Used heap dump 6.3 MB 
Number of objects 107,526 
Number of classes 2,397 
Number of class loaders 11 
Number of GC roots 1,474 
Format hprof 
JVM version  
Time 12:45:47 PM GMT+08:00 
Date Aug 2, 2013 

Leak Suspect.

25 instances of "com.mysql.jdbc.JDBC4Connection", loaded by "sun.misc.Launcher$ExtClassLoader @ 0xf00469b0" occupy 3,278,240 (49.74%) bytes. 

Biggest instances:

•com.mysql.jdbc.JDBC4Connection @ 0xf01d4d18 - 225,448 (3.42%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf0340da0 - 216,896 (3.29%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf027fe78 - 195,888 (2.97%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf02362a0 - 182,760 (2.77%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf00093f0 - 146,816 (2.23%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf01de7f8 - 134,592 (2.04%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf0194428 - 133,280 (2.02%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf0351b48 - 128,600 (1.95%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf02b2470 - 126,728 (1.92%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf02f2320 - 119,288 (1.81%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf00e4ae0 - 117,528 (1.78%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf013c768 - 117,168 (1.78%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf0001660 - 117,000 (1.78%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf019e1f0 - 115,528 (1.75%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf0349588 - 114,800 (1.74%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf00f0c58 - 113,872 (1.73%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf0005200 - 113,832 (1.73%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf0189b38 - 112,304 (1.70%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf01fd728 - 112,176 (1.70%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf0208b90 - 111,544 (1.69%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf00064f8 - 111,512 (1.69%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf00a3b18 - 107,984 (1.64%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf0288ba0 - 107,752 (1.63%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf01f8850 - 99,544 (1.51%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf035ebd0 - 95,400 (1.45%) bytes. 


Keywords
com.mysql.jdbc.JDBC4Connection
sun.misc.Launcher$ExtClassLoader @ 0xf00469b0

Details »

第二个样本

Used heap dump 13.2 MB 
Number of objects 253,698 
Number of classes 2,440 
Number of class loaders 11 
Number of GC roots 1,521 
Format hprof 
JVM version  
Time 6:02:49 PM GMT+08:00 
Date Aug 15, 2013 

Leak Suspect.

The class "java.lang.ref.Finalizer", loaded by "<system class loader>", occupies 2,419,168 (17.52%) bytes. 

Keywords
java.lang.ref.Finalizer


Details »  Problem Suspect 2
23 instances of "com.mysql.jdbc.JDBC4Connection", loaded by "sun.misc.Launcher$ExtClassLoader @ 0xf00469b0" occupy 8,373,160 (60.65%) bytes. 

Biggest instances:

•com.mysql.jdbc.JDBC4Connection @ 0xf035ebd0 - 1,338,136 (9.69%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf187b6f8 - 799,496 (5.79%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf1aeaa70 - 559,488 (4.05%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf183b688 - 508,680 (3.68%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf0340da0 - 457,120 (3.31%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf0349588 - 452,088 (3.27%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf01fd728 - 442,312 (3.20%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf01de7f8 - 441,344 (3.20%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf197e3d8 - 441,256 (3.20%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf00093f0 - 380,872 (2.76%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf0001660 - 315,384 (2.28%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf0005200 - 315,128 (2.28%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf01f8850 - 313,024 (2.27%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf210faa8 - 262,040 (1.90%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf1d74e90 - 259,072 (1.88%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf197b5f0 - 216,224 (1.57%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf1837688 - 190,848 (1.38%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf1af2a90 - 173,760 (1.26%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf1d71058 - 150,576 (1.09%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf2111d20 - 142,128 (1.03%) bytes. 


Keywords
com.mysql.jdbc.JDBC4Connection
sun.misc.Launcher$ExtClassLoader @ 0xf00469b0

Details »

第三个样本

Used heap dump 20.1 MB 
Number of objects 414,028 
Number of classes 2,440 
Number of class loaders 11 
Number of GC roots 1,517 
Format hprof 
JVM version  
Time 9:53:04 PM GMT+08:00 
Date Aug 23, 2013 

泄密嫌疑人

 Problem Suspect 1
The class "java.lang.ref.Finalizer", loaded by "<system class loader>", occupies 3,665,768 (17.35%) bytes. 

Keywords
java.lang.ref.Finalizer


Details »  Problem Suspect 2
19 instances of "com.mysql.jdbc.JDBC4Connection", loaded by "sun.misc.Launcher$ExtClassLoader @ 0xf00469b0" occupy 14,680,064 (69.48%) bytes. 

Biggest instances:

•com.mysql.jdbc.JDBC4Connection @ 0xf1837688 - 1,433,840 (6.79%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf183b688 - 1,351,640 (6.40%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf01f8850 - 1,199,280 (5.68%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf187b6f8 - 1,183,600 (5.60%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf0349588 - 1,162,328 (5.50%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf1af2a90 - 1,074,768 (5.09%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf210faa8 - 911,432 (4.31%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf197e3d8 - 910,184 (4.31%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf1d74e90 - 852,224 (4.03%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf0005200 - 795,664 (3.77%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf1d71058 - 791,720 (3.75%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf197b5f0 - 780,608 (3.69%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf244d520 - 689,128 (3.26%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf2111d20 - 621,304 (2.94%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf3876b20 - 328,280 (1.55%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf3863598 - 321,656 (1.52%) bytes. 


Keywords
com.mysql.jdbc.JDBC4Connection
sun.misc.Launcher$ExtClassLoader @ 0xf00469b0

Details »

1 个答案:

答案 0 :(得分:1)

您是否检查过以确保在完成所有数据库资源后始终close()?{/ p>