Downloading a file via Newman, run out of memory

Hi,

If I have a decent size file to Download (i.e. am pulling the file from a server), in this case a 17 MB file, Newman crashes due to lack of memory (version 3.9.3) ONLY IF I include any JS test to verify the success of the download.

The data set is a 17 MB file on a system with 4 GB of memory.

If I have the following defined as my “test”, under the “Tests” heading:
pm.test(“Download Status code is ( 200 )”, function () {
pm.response.to.have.status(200);
pm.test(“Download Status string is { OK }”, function () {
pm.response.to.have.status(“OK”);
});
pm.response.to.not.be.error;
});

If I put ANY Javascript in the “Tests” section, I get an out of memory crash.

Even something innocuous like the following:

tests[“Hello World”] = 1 === 1;

will result in a crash.

If I use a 7 MB file this works.

Is Newman/Postman somehow cacheing all the Download information in memory so that
it can execute the “Tests” script which runs after the Download completes?

Is there any way to work around this? Like force cacheing off somehow?

Has anyone else seen something like this?

Thanks.

–Jim

Can you try increasing the memory allocated to Newman and also use Newman in Node v9 or above?

The reason why there’s a drastic drop in memory if tests are added is because Newman tries to bypass test related memory allocation and file parsing if no script is required to run. Otherwise, memory allocated to a process can be limited by a number of variables.

There’s a small thing you can do @jamesp.hurl, but that’s undocumented and private for now, is add "use sandbox2"; as the first line of your scripts. That would turn off all older and deprecated sandbox features (like responseBody global variable) leaving some additional space in memory.

There’s also a GitHub thread where a similar issue has been recently reported. https://github.com/postmanlabs/newman/issues/1700

@kunagpal @udit.vasu we should see if we can detect this from within runtime (from response content length and allocated process memory) and give early warning + remedial messages. We should also try and print available memory and other helpful information at the beginning of the run where we print the Newman banner in CLI.