LoginSignup
0
0

More than 5 years have passed since last update.

Nodejsでメモリ使用量を監視する

Last updated at Posted at 2019-01-26
memory_monitoring.js
while(1){
    /*
    ~~~~~~~処理~~~~~~~~~
    */

    let used = process.memoryUsage();
    let messages = [];
    for (let key in used) {
        messages.push(`${key}: ${Math.round(used[key] / 1024 / 1024 * 100) / 100} MB`);
    }

    //rss: プロセス全体が使っているメモリ使用量。topコマンドなどで出力させる値
    //heapTotal: プログラム中で作成したオブジェクトが使用しているメモリの総量

    console.log(new Date(), messages.join(','));
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0