I have a memory dump file which has nearly 5000 instances of a particular object. These objects are to be written into a DB, and the way i am doing this is to write an OQL query in jvisualvm to generate a string that will serve as an SQL insert for example
select "insert into trades (id, tradeNumber) values ("+ x.id+ ", " + x.tradeNumber +");" from com.test.application.TradeObject x;
When i run this via OQL, i get a result set like this -
<code>
insert into trades (id, tradeNumber) values (1,12345);
insert into trades (id, tradeNumber) values (2,123456);
insert into trades (id, tradeNumber) values (3,123457); </code>
etc
However, since the total number of instances is large (around 5000) JvisualVM only shows about 100 of them. and then errors out with a message "Too many results. Please, refine your query."
I cannot refine the query as i have to parse all instances this way. Is there a way in which i can ask JvisualVM to show me all instances and not restrict the number of results?
I also see that Jvisual vm shows the first 100 instances without any filters, is it possible to get the next 100 instances and so on via OQL query?
Thanks
I couldn't find any settings in jvisualVm to increase the size of resultset. May be its not possible that way. It looks like a hard coded limit in Jvisualvm code base. Ref: http://visualvm.sourcearchive.com/documentation/1.3/OQLController_8java-source.html
find below snippets there:
and
Now the interesting part, the workaround for your problem.
Consider the class below :
now say I have 105 objects in memory for this class, kept in a list like :
and I need to achieve what you are doing.
Now to show these 105 objects instead of listing all the result sets, i would rather iterate over all the objects and create one single string containing all the SQL queries separated by new line. For this you need to invoke similar OQL script in
Query Editor
.and the result in
Query Results
tab will be:just modify the OQL script to suit your requirement.
NOTE: in class Xyz the field idXyz was
intentionally not set as id
, as in that caseitr.id
will return object id associated with that instance.for more on OQL methods ref: http://visualvm.java.net/oqlhelp.html#toHtml
Now it is possible (v 1.7), from
netbeans/profiler.heapwalker/src/org/netbeans/modules/profiler/heapwalk/OQLController.java
:My helper code (if you skip
limit
- then unlimited):UPDATE Another trick that I found is assigning value to variable:
Resulted object has interface
next()
/hasNext()
which is used by viewer. By default it shown 100 entries. But next call on only:shown next 100 entries and so on... !
Open
visualvm.conf
file:add to a string started with
a property with your desirable limit value