0
votes

target:

  • simulator 10 users download the file from the server
  • the file size more than 300M
  • use HTTP request sampler to download file on the Nginx server with bean shell script.

result:

  • success 2/10

  • jmeter log :java.lang.OutOfMemoryError: Java heap space

configure in jmeter.bat:

  • set HEAP=-Xms1024m -Xmx3072m

  • set NEW=-XX:NewSize=512m -XX:MaxNewSize=1024m

please help, thanks.

bean shell script

   import java.io.*;

   byte[] result=prev.getResponseData();
   String file_name="d:\\update.txt";
   String key=vars.get("name");
   String newname=file_name+key;
   File file=new File(newname);
   FileOutputStream out=new FileOutputStream(file);
   out.write(result);
   out.close();
1

1 Answers

0
votes
  1. If you have 10 concurrent downloads of the file which is more than 300 megabytes you will need at least 4 GB of heap space in order to fit everything (and looking into your "code" it would rather be around 10 GB), if it's not enough measure heap usage for 1 user and 2 users using i.e. JVisualVM and extrapolate it for 10 users
  2. Don't use Beanshell for scripting
  3. If you need to save response to the local drive it's better to go for Save Responses to a file listener, check out Performance Testing: Upload and Download Scenarios with Apache JMeter for more details if needed