| Author |
How can i track unclosed connection in my code ?
|
RaviNada Kiran
Ranch Hand
Joined: Jan 30, 2009
Posts: 528
|
|
Hello please suggest your ideas on
How can i track connection which are not closed on to a Application. (so that instead of worrying about memory leak later )
Waiting for your suggestions and ideas on this .
|
If you want something you never had do something which you had never done
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26201
|
|
|
You could use a monitoring tool to check it at runtime or a static analysis tool to find some cases at build time.
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
RaviNada Kiran
Ranch Hand
Joined: Jan 30, 2009
Posts: 528
|
|
|
Can you please tell the names of those tools .(except Jamon as its learning curve is high)
|
 |
RaviNada Kiran
Ranch Hand
Joined: Jan 30, 2009
Posts: 528
|
|
|
will FindBugs suit for this requirement ?
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26201
|
|
RaviNada,
I've never needed a tool to do this as I use a framework that handles closing resources for me. It would be equal effort to go through the tools (google the categories I listed) to find out which ones support your requirement. Or maybe you'll be lucky and someone who sees this Monday will have had the same requirement as you and knows the solution off the top of their head.
For FindBugs, you already know the name of the tool making it easy to find this information. FindBugs has the list of rules online. The ODR ones look like what you need.
|
 |
Moojid Hamid
Ranch Hand
Joined: Mar 07, 2009
Posts: 120
|
|
|
You can subclass the "connection" and keep a count of open connections, you will have to make sure that only the subclass is being used in the application.
|
 |
steve souza
Ranch Hand
Joined: Jun 26, 2002
Posts: 852
|
|
Not sure you will get a solution any easier than jamon.
- Connect to the database with the jamon jdbc proxy driver
- install the war to view the jdbc/sql stats.
If you have specific questions feel free to ask follow up questions. Here is a link that shows how to connect with the jamon proxy driver. http://jamonapi.sourceforge.net/#WhatsNew22
|
http://www.jamonapi.com/ - a fast, free open source performance tuning api.
JavaRanch Performance FAQ
|
 |
Tim Holloway
Saloon Keeper
Joined: Jun 25, 2001
Posts: 14491
|
|
The Apache dbcp connection pooler can be configured to take a stack snapshot when you acquire a connection. The snapshot is then saved, and if you end up with leaks, it can be dumped, so you'll know where it was opened.
However, the ability to ensure that connections don't leak is one of the primary reasons I use the Spring Framework to manage my persistency layers. I've seen too much hand-written code that forgot to free up stuff when an unexpected SQL exception was thrown.
|
Customer surveys are for companies who didn't pay proper attention to begin with.
|
 |
 |
|
|
subject: How can i track unclosed connection in my code ?
|
|
|