dcodeIO/grunt-closurecompiler — pull request #5 by izb (2013-11-04 22:13:20+00:00)
Title: Limit max processes and remove timer

In the current grunt task, there are as many java processes spawned as there are files to be processed. Normally, this isn't a problem. The problem comes where a task contains a lot of files. Java can be a bit of a memory hog, and spawning a large number of java processes can very quickly lead to out-of-memory states.

This patch adds an optional 'max_processes' setting that limits the number of closure processes that can run in memory at a time. By default, it keeps the default behaviour of spawning as many as possible.

The task queues files up and spawns new closure instances only when another one exits, leaving room for the next.

This patch also has the benefit of removing the timer-based method of checking that all processes have completed, so it's possible that running this task will now complete slightly more quickly.