镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Hello world take so many memory #222

Description

@batobolg
  • Version:v4.4.7
  • Platform: Linux ainode06 3.10.0-327.10.1.el7.x86_64 Update README for help #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 ?

Activity

  1. Knighton910 commented on Jul 13, 2016

    @Knighton910
    Contributor

    Here's what I'm getting from the same code, but diff system:

    screen shot 2016-07-13 at 1 42 47 pm


    But Let me check, if i can help you with yours

  2. Knighton910 commented on Jul 13, 2016

    @Knighton910
    Contributor

    click me 🔗

    this article is touches on some problems with cent os & nodejs in development mode, but really is going in detail about the two in hosting & deploying -- specifically --

    """ Just like on your development machine you can run node app.js on your server and your code will be executed perfectly.

    However, this is far from ideal and there are many problems with it. Let’s look at just a few of them.

    Serving static files, like JavaScript, images & CSS, can be done with node but it is not very efficient. It will use too much memory and it might not cache frequently accessed files, which in result can make your Node app slow or even crash it. """


    click me 🔗

    The Installing Node.js via package manager page has a nice page with specific sections about
    CENT OS


    [personal opinion]

    I think from what i searched is, there isn't a plethora amount of nodejs & cent os experience going on
    but i'm sure you will find enough to get by to fix your problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions