| Extracting large String values from an array (or Collection) [message #1320099]
||Mon, 28 April 2014 15:40
| Dan Gravell
Registered: November 2011
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:
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
| Andrew Johnson
Registered: July 2009
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
Powered by FUDForum
. Page generated in 0.01615 seconds