https://issues.apache.org/bugzilla/show_bug.cgi?id=54990
Bug ID: 54990
Summary: Download large files avoiding outOfMemory
Product: JMeter
Version: 2.9
Hardware: PC
OS: Windows XP
Status: NEW
Severity: enhancement
Priority: P2
Component: HTTP
Assignee: [email protected]
Reporter: [email protected]
Classification: Unclassified
During tests of my web application, I need to download large file and save it
on disk. To accomplish this I use an http request with a POST method to request
the file and a "Save Response to a file" listener to save on disk the file. The
size of the file to download is 441MB. My Jmeter (executed inside Windows XP 32
bit) started with -Xms1536m -Xmx1536m but, however, it goes to an OutOfMemory
when start to write the file.
Debugging the source I notice that the OutOfMemory succeed in the class
ResultSaver.java, specifically at this line
pw.write(s.getResponseData());
of the method:
private void saveSample(SampleResult s, int num)
When java call s.getResponseData(), it get an array of byte of the size 441MB.
The write method of the FileOutputStream class allocates the same space for
writing data to a file, causing OutOfMemory.
I have resolved this problem deleting the listener "Save Response to a file"
and adding "BeanShell PostProcessor" with this code:
final int BUFFER_SIZE = 65536;
FileOutputStream fos = new
FileOutputStream("c:\\temp\\roberto\\ranemetestdwn.zip");
for(int i = 0; i < data.length; i += BUFFER_SIZE) {
fos.write(data, i, Math.min(data.length-i, BUFFER_SIZE));
}
fos.close();
Writing the file recursively, with a buffer of 64KB, none OutOfMemory error
occur.
Then, if no other side effects exist, I propose to use similar code in class
ResultSaver.java, in place of
pw.write(s.getResponseData());
--
You are receiving this mail because:
You are the assignee for the bug.