Extracting large String values from an array (or Collection) [message #1320099] |
Mon, 28 April 2014 15:40  |
Eclipse User |
|
|
|
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¶m2=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] by Moderator 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   |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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 #1324196 is a reply to message #1324158] |
Wed, 30 April 2014 17:07   |
Eclipse User |
|
|
|
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  |
Eclipse User |
|
|
|
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.
|
|
|
Powered by
FUDForum. Page generated in 0.08175 seconds