Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Memory Analyzer » Extracting large String values from an array (or Collection)
icon5.gif  Extracting large String values from an array (or Collection) [message #1320099] Mon, 28 April 2014 15:40 Go to next message
Dan Gravell is currently offline Dan GravellFriend
Messages: 4
Registered: November 2011
Junior Member
I have a large array of 640 NameValuePairs (see the Apache HTTPClient project, sorry, I cannot link). These are parameters passed in a POST. The POST itself is causing an OOME in my code, so I want to replicate the call to see how I can fix it.

I have -XX:+HeapDumpOnOutOfMemoryError set so I am able to grab a heap dump and open it in Memory Analyzer. Thus, I see the above as the cause of the OOME.

Eventually I want to replicate the post with a request body of:

param1=blah&param2=fah...


Where "paramN" is the name of the NameValuePair and blah etc are the values.

Ideally, I'd like a way of "mapping" the array in Memory Analyzer and making a string from the results so I can replicate the call (think map and mkstring in functional languages or Joiner and Iterables.transform in Guava). But that might be asking too much. So, just a way of extracting all the values would be nice and I can do the rest with sed.

Some of the String 'values' in these objects are large - or at least larger than 1KB.

The closest I've got is the following OQL:

SELECT toString(s.name), toString(s.value.value) FROM org.apache.commons.httpclient.NameValuePair s 


This gives me a list of all the parameters, but when I export them the "toString(s.value.value)" is truncated.

How can I get this data out intact?

v 1.3.0 btw.

[Updated on: Tue, 29 April 2014 09:14]

Report message to a moderator

Re: Extracting large String values from an array (or Collection) [message #1322053 is a reply to message #1320099] Tue, 29 April 2014 17:06 Go to previous messageGo to next message
Andrew Johnson is currently offline Andrew JohnsonFriend
Messages: 205
Registered: July 2009
Senior Member
You could try the Copy > Save Value To File query.
That copies the entire String, StringBuilder, StringBuffer or char[] to a file,
one from each line selected.

It gets a bit tricky as you have two strings per line, but perhaps you could run three OQL commands, one with 2 short strings, one with the keys from the long strings and one with the long strings, and just run the Save Value to File query on the long one, and piece the results together.

SELECT toString(s.name), toString(s.value.value) FROM org.apache.commons.httpclient.NameValuePair s where toString(s.value.value).@length() < 1000
SELECT toString(s.name) FROM org.apache.commons.httpclient.NameValuePair s where toString(s.value.value).@length() >= 1000
SELECT toString(s.value.value) FROM org.apache.commons.httpclient.NameValuePair s where toString(s.value.value).@length() >= 1000

Re: Extracting large String values from an array (or Collection) [message #1323478 is a reply to message #1322053] Wed, 30 April 2014 09:25 Go to previous messageGo to next message
Dan Gravell is currently offline Dan GravellFriend
Messages: 4
Registered: November 2011
Junior Member
Thanks. However when I run "Save Value To File" the actual values selected aren't saved... instead some representation of the owning object is saved. If I run the first query and select all rows in the query results (apart from the header regex filter row) I get:

org.apache.commons.httpclient.NameValuePair @ 0x32e8d6f8
org.apache.commons.httpclient.NameValuePair @ 0x32e8d650
org.apache.commons.httpclient.NameValuePair @ 0x32e8d5a8
org.apache.commons.httpclient.NameValuePair @ 0x32e8d500
org.apache.commons.httpclient.NameValuePair @ 0x32e8d458
org.apache.commons.httpclient.NameValuePair @ 0x32e8d3b0
... [and so on]


I would expect the toString(s.name) and toString(s.value.value) columns.
Re: Extracting large String values from an array (or Collection) [message #1324158 is a reply to message #1323478] Wed, 30 April 2014 16:43 Go to previous messageGo to next message
Andrew Johnson is currently offline Andrew JohnsonFriend
Messages: 205
Registered: July 2009
Senior Member
Good point - Save Value To File does just take the underlying object for the row.
A way to fix it is
SELECT objects s.value.value FROM org.apache.commons.httpclient.NameValuePair s where toString(s.value.value).@length() >= 1000

then run the Save Value To File query on the rows.
Re: Extracting large String values from an array (or Collection) [message #1324196 is a reply to message #1324158] Wed, 30 April 2014 17:07 Go to previous messageGo to next message
Andrew Johnson is currently offline Andrew JohnsonFriend
Messages: 205
Registered: July 2009
Senior Member
It looks like there is a bug in Save Value To File for dumps from Java 7 and later where Strings do not have count and offset fields. Those Strings will be output with the name resolver so will be escaped and truncated.

Also, what should that query do with unprintable characters? Currently it just outputs them as is, rather than escaped as with toString() and name resolvers.
Re: Extracting large String values from an array (or Collection) [message #1325768 is a reply to message #1324196] Thu, 01 May 2014 11:23 Go to previous message
Dan Gravell is currently offline Dan GravellFriend
Messages: 4
Registered: November 2011
Junior Member
Excellent, I was able to recreate the query using that.

I'm not sure if the behaviour should be different for unprintable characters. Is not the point of the object expression in an OQL query is to output the object as-is... if you want to handle the unprintable characters in some way then OQL should allow access to other facilities to perform this manipulation in the same way toString is offered.
Previous Topic:How to find a value by map key in by OQL
Next Topic:How to create heap dump for spring based web application running in weblogic
Goto Forum:
  


Current Time: Thu Apr 25 23:26:43 GMT 2024

Powered by FUDForum. Page generated in 0.03729 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top