Re: Debugging my Connector/J based Tomcat Servlet

Ronald Klop <[email protected]> Fri, 10 Jul 2009 11:04:44 +0200 (CEST)
Newsgroups gmane.comp.db.mysql.java
Message-ID <1872523759.22259.1247216684340.JavaMail.tomcat@localhost>
This is a neat tool.
http://www.eclipse.org/mat/

jmap -dump:live,format=b,file=mymemoryproblem.hprof <pid>

Than open the hprof file in mat and you can very easily browse through the references to all the live objects. Works very well for me. Also on big dump files. I run it succesfully on a dump of 1.5GB.

Ronald.

Op vrijdag, 10 juli 2009 10:26 schreef Niklas Saers <[email protected]>:
> 
> Hi guys,
> I'm having a problem with my servlet that runs on Tomcat and uses
> Connector/J 5.1.7 to connect to MySQL. I'm quite certain that I don't keep
> any database objects laying around in my servlet, yet the JVM fills up. I
> used jmap to do a histogram of the running servlet, and it's filled with
> database-related objects that I thought should have been garbage-collected
> long ago:
> 
> | class                                                                |
> bytes    | count  |
> +----------------------------------------------------------------------+----------+--------+
> | com.mysql.jdbc.Field                                                 |
> 55555488 | 385802 |
> | com.mysql.jdbc.ByteArrayRow                                          |
> 10269536 | 641846 |
> | com.mysql.jdbc.ResultSetImpl                                         |
> 5166128 |  29353 |
> | com.mysql.jdbc.StatementImpl                                         |
> 3972528 |  27587 |
> | com.mysql.jdbc.Field[]                                               |
> 1841728 |  18926 |
> | com.mysql.jdbc.PreparedStatement                                     |
> 349856 |   1508 |
> | com.mysql.jdbc.RowDataStatic                                         |
> 141600 |   5900 |
> | com.mysql.jdbc.PreparedStatement$ParseInfo                           |
> 60320 |   1508 |
> | com.mysql.jdbc.Buffer                                                |
> 40080 |   1670 |
> | com.mysql.jdbc.DatabaseMetaData                                      |
> 36312 |   1513 |
> | com.mysql.jdbc.ConnectionPropertiesImpl$BooleanConnectionProperty    |
> 34240 |    535 |
> | com.mysql.jdbc.ConnectionPropertiesImpl$StringConnectionProperty     |
> 8960 |    140 |
> | com.mysql.jdbc.ConnectionPropertiesImpl$IntegerConnectionProperty    |
> 8000 |    125 |
> | com.mysql.jdbc.ConnectionImpl                                        |
> 5360 |      5 |
> | com.mysql.jdbc.VersionedStringProperty                               |
> 2112 |     66 |
> | com.mysql.jdbc.MysqlIO                                               |
> 1120 |      5 |
> | com.mysql.jdbc.ConnectionPropertiesImpl$MemorySizeConnectionProperty |
> 1080 |     15 |
> | com.mysql.jdbc.ConnectionPropertiesImpl$LongConnectionProperty
> |      360 |      5 |
> | com.mysql.jdbc.util.ReadAheadInputStream
> |      160 |      5 |
> | com.mysql.jdbc.StandardSocketFactory
> |      120 |      5 |
> | com.mysql.jdbc.log.StandardLogger
> |       80 |      5 |
> | com.mysql.jdbc.SingleByteCharsetConverter
> |       48 |      3 |
> | com.mysql.jdbc.Driver
> |       16 |      2 |
> | com.mysql.jdbc.log.NullLogger
> |        8 |      1 |
> 
> I have no idea why 385802 fields should be laying around or 29353 resultsets
> and 27587 statements. Do you have any suggestions as to what's going on, or
> how I can debug this?
> 
> Cheers
> 
>     Nik
>  
> 
> 
>