This discussion is archived
2 Replies Latest reply: Oct 17, 2011 6:40 AM by 800151 RSS

Perfomance Tunig VisualVM, Query Console - Search using OQL?! What is an ov

800151 Newbie
Currently Being Moderated

I am currently Profiling a Java Application with Java VisualVM (JDK 6.0.25)

When you use that tool to create a Heap Dump you can inspect the data in memory, that is nice but of course you can hardly click through 250.000 items to see if what class the chars/strings whatever belongs to.

But luckily there is a SQL like query editor ... however the syntax is bit tricky:

What I am searching for is all chars/strings that belong to a class called "ErrorPrinter".
How would you define such query?

Further: There is a sample query to find out "Overallocated String" ... well either my english is not good enough or I don't know ... but can anybody explain: What is an overallocated String and how to resolve that?

I have read the but it does not contain so much ...

Thank you very much,
Sebastian Wagner
  • 1. Re: Perfomance Tunig VisualVM, Query Console - Search using OQL?! What is an ov
    894519 Newbie
    Currently Being Moderated
    Hi Sebastian!

    "Overallocated String" means a string which effective data (denominated by its "offset" and "count" properties) take less space than allocated by its "value"
    Regarding the second part of your question - what do you mean by all strings/chars belonging to a class? Could you elaborate the usecase?


    Jaroslav Bachorik
  • 2. Re: Perfomance Tunig VisualVM, Query Console - Search using OQL?! What is an ov
    800151 Newbie
    Currently Being Moderated
    Thanks for your answer,

    I understand now the meaning of overallocated in that sense,

    the use-case for the search that I would like to perform in the Query Console is:

    I made a HEAP-Dump using VisualVM, now I analyze the Heap-Dump.

    char[] is the biggest memory consumer in that HEAP-Dump. Each char has some references, if you click through those references at some point you will reach a class that is part of my code.

    Now I would like to find out which classes do have the upmost consumers of "char" references in the HEAP-Dump.

    For example I have a class ErrorEvaluatorAsciiText that has an attribute "String" now I want to search the heap if there is any (and how many / size) of that String stored in the HEAP-Dump.

    Select count(s) from java.util.char where s.reference=ErrorEvaluatorAsciiText

    I can perform a query like:
    select o from char[] o where o.rererence=String

    but I can't do any query like:
    select o from java.lang.String o where o.rererence=StromElement

    Results in:
    Please, check the oql queryjavax.script.ScriptException: ReferenceError: "StromElement" is not defined. (#1)
    => But actually of course the interesting part for me is to see how many string-instances of the current heap have referals this class.

    or for example:
    select o from int[] o where o.rererence=SimpleVisitable
    select o from int[] o where o.rererence=priorityWasSetForVisitNr

    But actually from the VisualVM "Instances" view I can see that there is at least one int[] that has Type SimpleVisitable or Field priorityWasSetForVisitNr as reference.

    Even better of course would be a query that gives me the top10 references of char[] in my code...

    Hope this explains my problem ...



  • Correct Answers - 10 points
  • Helpful Answers - 5 points