20

I am using VisualVM to analyze a core dump. I suspect some XML objects to be causing the leak but there are way too many String objects to go through one by one.

Can I use OQL to search String that begin with 'GH' ?

thanks for any help.

Geek
  • 23,089
  • 20
  • 71
  • 85

4 Answers4

30

under JDK 1.8.20 a more simple variant works:

select s from java.lang.String s where s.toString().startsWith("GH")
Yura
  • 1,733
  • 1
  • 20
  • 19
  • Thank you for this. Where do you find documentation for all the supported methods? Googling only leads to random blogs that don't work – higuaro Mar 29 '23 at 04:59
  • just looked at the answer below and guessed that startsWith could work. also as I heard it's possible to use sql with a heap dump – Yura Mar 30 '23 at 14:42
24

Try this: select {instance: s, content: s.toString()} from java.lang.String s where s.count>2 && s.toString().substring(0,2)=="GH"

Tomas Hurka
  • 6,723
  • 29
  • 38
6
heap.objects('java.lang.String', false, "it.toString().startsWith('GH')")
Bulat
  • 61
  • 1
  • 1
  • 8
    A short ummary would help reviewers (like me) to judge the validity of your answer; interested users wouldn't have to dive into the code to understand your appoach. Just a sentence or two would be fine and not too much work. – Ingo Karkat Dec 22 '16 at 15:07
-1

select c.attr_name.toString() from a.b.c.MyClass c where c.attr_name.toString().startsWith("GH")