Why am I running out of heap space in child processes?


I’m trying to write an Atom linter based on Scala’s SBT build tool. I’m spawning child processes that call the sbt CLI utility directly. However, SBT always fails with an out-of-memory exception, running out of heap space:

@cwd = atom.project.path
command = @executablePath + '/' + @cmd
console.log('[linter-sbt] executing command=[' + command + ']')

sbt = spawn(command, ['-v', 'compile'])

sbt.stdout.on('data', (data) ->
    console.log('[linter-sbt] stdout: ' + data)

sbt.stderr.on('data', (data) ->
    console.log('[linter-sbt] stderr: ' + data)

When I run the same command from command line directly, or from a vanilla Nodejs script it runs fine.

Am I doing something wrong?


I’d take a look at Atom’s BufferedProcess class to see if there are any hints in there as to what might be going wrong or best practices.


Using BufferedProcess didn’t seem to do anything unfortunately. Does Atom restrict the memory of its heap processes?


No idea. But to my understanding a couple of the autocomplete-plus providers spawn child processes, so there is a solution somewhere.


They all seem to call child_process.spawn in a similar way. My code is also forked from an existing project Linter project that calls a less memory intensive Scala process.

Is there someone on the development team I could contact who might know why I’m getting memory problems only from within Atom?


You can join the Slack channel or file a bug and ask there. Filing a bug is probably best for detailed documentation of exactly what it is you’re doing and what is happening. The more information you can give, the better. The Slack channels will get a lot more eyes on it though, potentially.