Hi Georg,
Try calling processEvents() and gc() inside the main loop:
for ( var j = 0; j < w.length; ++j )
{
// Write the output image.
// Force ImageWindow to disable all format and security features:
// * Query format-specific options
// * Warning messages on missing format features (icc profiles, etc)
// * Strict image writing mode (ignore lossy image generation)
// * Overwrite verification/protection
w[j].saveAs( outputFilePath, false, false, false, false );
// Close the image window.
// Note that we haven't called w.show(), so it is hidden.
w[j].close();
// Empty PI's event queue
processEvents();
// Perform a hard garbage collection
gc();
}
Let's see if this forces the images to close immediately. The problem here seems to be that PI is scheduling destruction of ImageWindow's internal structures, for the sake of performance. With little free RAM this can cause out-of-memory problems.