Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory cannot be freed in nodejs #14

Open
zyc9012 opened this issue Apr 19, 2018 · 1 comment
Open

Memory cannot be freed in nodejs #14

zyc9012 opened this issue Apr 19, 2018 · 1 comment

Comments

@zyc9012
Copy link

zyc9012 commented Apr 19, 2018

I create a stockfish() instance for each game on my server (nodejs), the memory was growing larger and larger when opening new games, but didn't go down when a game was destroyed.

I made a small experiment:

const stockfish = require('stockfish')
const readline = require('readline')

let s = null
const rl = readline.createInterface(process.stdin, process.stdout)
rl.setPrompt('> ')
rl.prompt()
rl.on('line', line => {
  rl.prompt()
  s = stockfish()
  s.onmessage = line => {
    console.log(line)
  }
  s.postMessage('quit')
  s.onmessage = null
  s = null
  global.gc()
}).on('close', () => {
  process.exit(0)
})

Each time I press enter, the memory increases by ~30MB, the memory doesn't go down even if I do manual GC (node --expose-gc test.js), sending quit command does not work either.

@michaldobiezynski
Copy link

Hey,
Not sure if you are still stuck on this problem but if anyone else is having a similar issue then you can try putting the stockfish function in a workerpool worker thread and terminating it after you are done using that particular stockfish instance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants