OQL in Eclipse memory analyzer - how to display array / ArrayList contents
Asked Answered
B

2

8

I have a dump which I opened with Eclipse Memory Analyzer.

I would like to export some contents of the heap into a file.

One of the fields I'm interested in is an ArrayList and I could not find a way to query the dump in a way that will return the contents of the array list as an output:

  • Selecting the ArrayList object itself returns something like: java.util.ArrayList [id=0xf2765680]

  • Selecting the array within the array list (select arr.elementData...) returns something like: java.lang.Object[] [id=0xf2765698;length=4]

  • Selecting toString(arr) or toString(arr.elementData) returns empty string when the arrayList isn't null (and the string null when it is).

Is it really impossible??

Brakeman answered 2/8, 2014 at 21:41 Comment(0)
G
9

To get list of elements

SELECT OBJECTS arr.@referenceArray FROM OBJECTS <your_array_address> arr

To re-map list of elements of array

SELECT OBJECTS elem.<field_name> FROM OBJECTS (SELECT OBJECTS arr.@referenceArray FROM OBJECTS <your_array_address> arr) elem

Real example

SELECT OBJECTS elem.callable.task.task FROM OBJECTS (SELECT OBJECTS arr.@referenceArray FROM OBJECTS 0x645eb6b80 arr) elem
Gerena answered 28/1, 2020 at 11:46 Comment(1)
Perfect! 3Q~~~~~Fireresistant
B
0

I encountered the same issue today with an array. I could not find a way to do this using OQL, but I did find a way using the Eclipse Memory Analyzer itself.

  1. Select the parent object of the data you want to export. Your collection should now show in the Attributes tab on the left of the screen.

  2. Right click the collection in the Attributes list and select Copy - Save Value to File or Copy - Value.

  3. If you choose Save Value to File, specify the file location. The contents of the collection will be output to the file.

Alternatively there appears to be an option to extract the values in a list.

  1. Right click the list.
  2. Select Java Collections - Extract List Values.

I have not attempted the second option but I hope this helps you or anyone else searching this topic.

Bridget answered 1/10, 2014 at 18:4 Comment(1)
Unfortunately, none of the options worked for me. Besides, extracting each list by itself is not an option for me because I had hundreds of array lists which I wanted to extract. I ended up with a query looks like select arrList.elementData[0].toString(), arrList.elementData[1].toString(), ... going on up to the size of the biggest array list I had. Ugly, but provided what I needed. Thanks.Brakeman

© 2022 - 2024 — McMap. All rights reserved.