Closed samgabriel closed 8 years ago
Could you submit a pull request to fix it?
Yes sure sorry just saw this
Hi There, I created the pull request. @milesibastos
@milesibastos did you have a change to review the pull request?
DONE: sorry for delayed review
@milesibastos great. When do you think a new release will be done?
DONE!!!
@milesibastos Great, I see it is released on github. Any idea when this will be available on Maven Central?
Sorry man... I dont know! Do u know how we can do it?
Hi There, We use jTDS to connect to SQL Server. Our setup includes using JNDI which requires the driver classes to be in Tomcat main classloader. Upon doing some profiling and memory dumps we found in at least one case a problem with jTDS lastWarning field keeping a reference to the a SQLWarning which is holding the last stack trace which is holding a reference to the Classloader. The problem seems to be that when creating a prepared statement and having an error this error is kept. Even thought the JtdsStatement calls messages.clearWarnings() this method doesn't clear the lastWarning and lastException field. Thus the entire class loader is held in memory.
The fix should be fairly easy as SQLDiagnostic.clearWarnings should reset the other variables as well.
Here is the stack from Eclipse Memory Analyzer
Class Name | Ref. Objects | Shallow Heap | Ref. Shallow Heap | Retained Heap
org.apache.tomcat.util.threads.TaskThread @ 0x17d82fc0 http-apr-8080-exec-9 Thread | 1 | 128 | 136 | 32,824 '- contextClassLoader java.net.URLClassLoader @ 0x10204ce8 | 1 | 80 | 136 | 1,155,784 '- classes java.util.Vector @ 0x103773c8 | 1 | 24 | 136 | 924,744 '- elementData java.lang.Object[2560] @ 0x1862e260 | 1 | 10,256 | 136 | 924,720 '- [283] class org.apache.tomcat.jdbc.pool.interceptor.StatementCache @ 0x107fa530 | 1 | 24 | 136 | 248 '- cacheSizeMap java.util.concurrent.ConcurrentHashMap @ 0x10b70138 | 1 | 64 | 136 | 168 '- table java.util.concurrent.ConcurrentHashMap$Node[16] @ 0x10b70178 | 1 | 80 | 136 | 104 '- [0] java.util.concurrent.ConcurrentHashMap$Node @ 0x10b701c8 | 1 | 24 | 136 | 24 '- key org.apache.tomcat.jdbc.pool.ConnectionPool @ 0x108ca8f0 | 1 | 56 | 136 | 54,472 '- idle org.apache.tomcat.jdbc.pool.FairBlockingQueue @ 0x108caee8 | 1 | 24 | 136 | 54,064 '- items java.util.LinkedList @ 0x108caf28 | 1 | 24 | 136 | 53,944 '- first java.util.LinkedList$Node @ 0x203ba2c0 | 1 | 24 | 136 | 15,584 '- item org.apache.tomcat.jdbc.pool.PooledConnection @ 0x108caf40 | 1 | 88 | 136 | 15,560 '- attributes java.util.HashMap @ 0x108e44a8 | 1 | 40 | 136 | 15,008 '- table java.util.HashMap$Node[16] @ 0x108e44d0 | 1 | 80 | 136 | 14,968 '- [5] java.util.HashMap$Node @ 0x10d328c0 | 1 | 24 | 136 | 14,840 '- value java.util.concurrent.ConcurrentHashMap @ 0x10d328d8 | 1 | 64 | 136 | 14,816 '- table java.util.concurrent.ConcurrentHashMap$Node[128] @ 0x187e06b0 | 1 | 528 | 136 | 14,752 '- [93] java.util.concurrent.ConcurrentHashMap$Node @ 0x194fcc30 | 1 | 24 | 136 | 168 '- val org.apache.tomcat.jdbc.pool.interceptor.StatementCache$CachedStatement @ 0x194fcc48 | 1 | 48 | 136 | 144 '- delegate com.sun.proxy.$Proxy98 @ 0x194a7d78 | 1 | 16 | 136 | 40 '- h org.apache.tomcat.jdbc.pool.interceptor.AbstractQueryReport$StatementProxy @ 0x194a7d88| 1 | 24 | 136 | 24 * '- delegate net.sourceforge.jtds.jdbc.JtdsPreparedStatement @ 0x194a7da0 | 1 | 120 | 136 | 71,056 '- messages net.sourceforge.jtds.jdbc.SQLDiagnostic @ 0x194b0218 | 1 | 32 | 136 | 1,048 '- lastWarning java.sql.SQLWarning @ 0x194b0238 | 1 | 40 | 136 | 1,016 '- backtrace java.lang.Object[4] @ 0x194b0260 | 1 | 32 | 136 | 800 '- [2] java.lang.Object[32] @ 0x194c0b88 * | 1 | 144 | 136 | 144
'- [21] class com.actbig.datahandler.service.DBService @ 0x14392ee0 | 1 | 24 | 136 | 24