node icon indicating copy to clipboard operation
node copied to clipboard

why hello world take so many memory ?

Open batobolg opened this issue 10 years ago • 2 comments

  • Version:v4.4.7
  • Platform: Linux ainode06 3.10.0-327.10.1.el7.x86_64 #1 SMP Tue Feb 16 17:03:50 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
  • Subsystem: CentOS 7

[bato@ainode06 nodejs]$ ./node-v4.4.7-linux-x64/bin/node -v v4.4.7


my server.js is


[bato@ainode06 node-v4.4.7-linux-x64]$ cat server.js

const http = require('http');

const hostname = '127.0.0.1';
const port = 3000;

const server = http.createServer((req, res) => {
  res.statusCode = 200;
  res.setHeader('Content-Type', 'text/plain');
  res.end('Hello World\n');
});

server.listen(port, hostname, () => {
  console.log(`Server running at http://${hostname}:${port}/`);
});

and after use ab command bench the nodejs memory like this


[bato@ainode06 ~]$ ps u

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
bato      6150  0.0  0.0 151024  1780 pts/2    R+   15:06   0:00 ps u
bato     17496  0.0  0.0 115472  2248 pts/1    Ss   13:48   0:00 -bash
bato     19341 12.2  0.1 913832 60144 pts/1    Sl+  13:54   8:45 bin/node server.js

i don't know why node js take 60144kb memory just for hello world program. any information ?

batobolg avatar Jul 13 '16 06:07 batobolg

Please post general support questions here: https://github.com/nodejs/help/issues

(I'll give you a hint though: lazy garbage collection.)

bnoordhuis avatar Jul 13 '16 06:07 bnoordhuis

thank you , i post to help.

batobolg avatar Jul 13 '16 06:07 batobolg