processes remaining open and leaking memory after killing main process
See original GitHub issueNWJS Version : 0.62.0 Operating System : Windows 10
Expected behavior
When the main nw.exe
process is killed, all child processes should also be killed. No nw.exe
processes should continue leaking memory until the system crashes.
Actual behavior
Intermittently, 2-3 nw.exe
processes will remain running after the “main” process is terminated. When this happens, those processes will continue increasing memory usage until the system runs out of memory and begins killing active processes.
How to reproduce
- Put the following files in a directory.
- Run:
node test.js
- Press CTRL+C in the terminal where step 2 was execute.
- Note that the NW.js application will “quit” but sometimes phantom
nw.exe
processes will remain running. - Watch those phantom
nw.exe
processes slowly chew through all available system memory.
package.json
{
"name": "bug",
"main": "bug.html"
}
bug.html
Hello
test.js
const { spawn } = require('child_process');
// Launch NW.js application
const proc = spawn('nw', ['.']);
console.log(`PID of child_process.exec() process: ${proc.pid}`);
// Kill app on CTRL+C
process.on('SIGINT', () => {
process.kill(proc.pid);
process.exit();
})
// Keep alive until NW.js application exits
let quit = false;
const keepAliveCallback = () => {
if (!quit) setTimeout(keepAliveCallback, 500);
};
keepAliveCallback();
proc.stdout.on('data', (data) => {
process.stdout.write(data);
});
proc.stderr.on('data', (data) => {
process.stderr.write(data);
});
proc.on('exit', () => {
quit = true;
});
Issue Analytics
- State:
- Created 2 years ago
- Comments:7
Top Results From Across the Web
c# - possible for a process to result in leaked memory after it is ...
Killing the parent process doesn't in itself guarantee that the child processes will terminate. This could look like a memory leak.
Read more >Physical Memory Leak by Terminated Processes - TechNet
So any process terminates, does not release 20K of Physical Memory and gradually, server crashes when complete Memory chews up. We did some...
Read more >How we find and fix OOM and memory leaks in Java Services
Unclosed streams and connections represent another cause for memory leaks. In general, the operating system only allows a limited number of open ...
Read more >Zombie Processes are Eating your Memory | Random ASCII
So, a zombie process is a process that has shut down but is kept around because some other still-running process holds a handle...
Read more >Memory leak - Wikipedia
In computer science, a memory leak is a type of resource leak that occurs when a computer program incorrectly manages memory allocations in...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Unfortunately, that is not a solution. It’s an ugly workaround that doesn’t work in many cases. That also kills valid
nw.exe
processes (from other apps), so can’t be done “automatically”.my application creates a socket server on the main process which renderers then connect to - funny thing is, if there has been a previous dirty exit with hung renderers, if you reopen the application, the new instance´s renderers connect to the older instance socket server, in the main thread that should not exist - so it also stays alive in my case and apparently responsive - however I cannot connect a debugger to it or its former renderers - the debugger does not connect.