Hi,
I am debugging an out of memory issue because of prepared statement not being closed .I am seeing thousands of prepared statement objects in pending finalization state. from my understanding, I can't pinpoint where in my code this leak is happening as these are weak references at this point of time. Is my understanding correct?
The prepared statement object has a string by name originalsql which contains the last executed sql . Is there a way to extract all the originalsql values from the heap dump from these thousands of object for us to pin point the leak in our code?
thank you
Ben
Extract a String value from object
-
- Posts: 6172
- Joined: Wed Aug 11, 2004 8:37 am
Re: Extract a String value from object
Hi Ben,
1. You can explicitly find non closed statements via the events:
https://www.yourkit.com/docs/java/help/probes_ui.jsp
To get results in Events, activate the probes by running CPU profiling e.g. CPU sampling or explicitly: https://www.yourkit.com/docs/java/help/ ... probes.jsp
There are dedicated inspections searching for non closed resources which work on events:
https://www.yourkit.com/docs/java/help/ ... ctions.jsp
2. Alternatively, if you want to work with a memory snapshot, please record object allocations:
https://www.yourkit.com/docs/java/help/allocations.jsp
You'll see for each recorded statement object where it was created.
Please note that object allocation recording will likely have higher profiling overhead than Probes, especially if you record all objects.
3. You cannot extract all strings by field, but can extract all strings from a memory snapshot. Not sure if it is helpful in your case.
Please see the "Export with command line tool" section at
https://www.yourkit.com/docs/java/help/export.jsp
Best regards,
Anton
1. You can explicitly find non closed statements via the events:
https://www.yourkit.com/docs/java/help/probes_ui.jsp
To get results in Events, activate the probes by running CPU profiling e.g. CPU sampling or explicitly: https://www.yourkit.com/docs/java/help/ ... probes.jsp
There are dedicated inspections searching for non closed resources which work on events:
https://www.yourkit.com/docs/java/help/ ... ctions.jsp
2. Alternatively, if you want to work with a memory snapshot, please record object allocations:
https://www.yourkit.com/docs/java/help/allocations.jsp
You'll see for each recorded statement object where it was created.
Please note that object allocation recording will likely have higher profiling overhead than Probes, especially if you record all objects.
3. You cannot extract all strings by field, but can extract all strings from a memory snapshot. Not sure if it is helpful in your case.
Please see the "Export with command line tool" section at
https://www.yourkit.com/docs/java/help/export.jsp
Best regards,
Anton