最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Find Memory Leak on Node.jsExpress.js Application - Stack Overflow

programmeradmin1浏览0评论

I have an Express.js web app which is constantly breaking because of memory problems:

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap
out of memory

When I start the service, the memory usage is about 170Mb (reported by htop as RES memory). Then I start throwing request at it, and the memory start rising. I'm using memwatch to try to track the problem in what looks like a memory leak, but a memwatch.HeapDiff() reports something like:

{ before: { nodes: 2093729, size_bytes: 197165296, size: '188.03 mb' },
  after: { nodes: 2491264, size_bytes: 232097040, size: '221.34 mb' },
  ...

... where I understand that the app is using 221.34mb for the heap; but with htop the memory usage is about 2GB when it breaks.

The question is, if my assumptions are right, what could be using non-heap memory that is still reported by htop as RES memory?

I have an Express.js web app which is constantly breaking because of memory problems:

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap
out of memory

When I start the service, the memory usage is about 170Mb (reported by htop as RES memory). Then I start throwing request at it, and the memory start rising. I'm using memwatch to try to track the problem in what looks like a memory leak, but a memwatch.HeapDiff() reports something like:

{ before: { nodes: 2093729, size_bytes: 197165296, size: '188.03 mb' },
  after: { nodes: 2491264, size_bytes: 232097040, size: '221.34 mb' },
  ...

... where I understand that the app is using 221.34mb for the heap; but with htop the memory usage is about 2GB when it breaks.

The question is, if my assumptions are right, what could be using non-heap memory that is still reported by htop as RES memory?

Share Improve this question asked Oct 14, 2016 at 14:49 Mr. GoferitoMr. Goferito 7,0514 gold badges27 silver badges27 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

I've seen this before , where memory reported in used was much smaller that memory as seen by htop.

In our case it was a memory leak in JavaScript that looked small, but when was fixed resolved the memory issue.

I wrote a post detailing the steps I took to diagnose it, it's too long to post in here.

https://techtldr./simple-guide-to-finding-a-javascript-memory-leak-in-node-js/

发布评论

评论列表(0)

  1. 暂无评论