Extract a String value from object

Questions about YourKit Java Profiler
Post Reply
DEinOgNiTArTeR
Posts: 1
Joined: Tue Sep 13, 2022 4:50 pm

Extract a String value from object

Post by DEinOgNiTArTeR »

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
Anton Katilin
Posts: 6143
Joined: Wed Aug 11, 2004 8:37 am
Contact:

Re: Extract a String value from object

Post by Anton Katilin »

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
Post Reply