V
V
vetsmen2018-04-11 12:01:36
Node.js
vetsmen, 2018-04-11 12:01:36

Memory leak in node.js?

Good day. There is a memory leak in node.js, after a day the application turns off, gives an error:

Security context: 0x1640faa57c1 <JSObject>
    1: stringSlice(aka stringSlice) [buffer.js:~555] [pc=0x3a41f7f9c024](this=0x3463f0022d1 <undefined>,buf=0xa552aeef399 <Uint8Array map = 0x1ee6abe43339>,encoding=0x3463f0022d1 <undefined>,start=0,end=488634)
    2: /* anonymous */ [/srv/server/node_modules/request/request.js:~1122] [pc=0x3a41f97bfd5b](this=0xa552aeeb8f1 <Request map = 0x2c36337e05b1>)
    3: arguments adaptor frame: 1->...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: node::Abort() [node]
 2: 0x11e7fec [node]
 3: v8::Utils::ReportOOMFailure(char const*, bool) [node]
 4: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [node]
 5: v8::internal::Factory::NewRawTwoByteString(int, v8::internal::PretenureFlag) [node]
 6: v8::internal::Factory::NewStringFromUtf8(v8::internal::Vector<char const>, v8::internal::PretenureFlag) [node]
 7: v8::String::NewFromUtf8(v8::Isolate*, char const*, v8::NewStringType, int) [node]
 8: node::StringBytes::Encode(v8::Isolate*, char const*, unsigned long, node::encoding, v8::Local<v8::Value>*) [node]
 9: 0x1207c96 [node]
10: 0x3a41f79d5b07

Do I understand correctly that the error is related to the /srv/server/node_modules/request/request.js module?
It's just that the problem is that I've disabled all the parts of the code where this module is used, but the problem remains.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly, 2019-08-30
@vshvydky

the problem is memory loss, usually due to the uncontrolled creation of subscriptions in the event emitter or the association of long-lived objects with short-lived ones.
the first thing you should start paying attention to the console of the running application, is there a warning about exceeding the number of listeners, if so, the leak is most likely there, if not, look for it, if you have enough experience, through code profiling, if not. then an explicit review of your code ....

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question