question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

There may be a memory leak

See original GitHub issue

What you are doing?

// code here

What do you expect to happen?

Recycle memory

What is actually happening?

Executed (24ea0587-4836-4ebe-b693-f73c931fa86d): START TRANSACTION;

<--- Last few GCs --->

33650985 ms: Mark-sweep 1313.0 (1403.6) -> 1312.6 (1404.6) MB, 1348.9 / 0.0 ms [allocation failure] [GC in old space requested].
33652499 ms: Mark-sweep 1312.6 (1404.6) -> 1312.6 (1404.6) MB, 1427.7 / 0.0 ms [allocation failure] [GC in old space requested].
33653995 ms: Mark-sweep 1312.6 (1404.6) -> 1316.6 (1403.6) MB, 1495.3 / 0.0 ms [last resort gc].
33655483 ms: Mark-sweep 1316.6 (1403.6) -> 1320.7 (1403.6) MB, 1488.3 / 0.0 ms [last resort gc].


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x3d6955fcfb39 <JS Object>
    2: select [/home/axetroy/gpm/github.com/axetroy/duomi-nodejs/node_modules/sequelize/lib/query-interface.js:~666] [pc=0x20d2722ece6e] (this=0x1455d4775e51 <a QueryInterface with map 0x12e141fcfc11>,model=0x8f39e5ba859 <JS Function model (SharedFunctionInfo 0x34ad626ecb51)>,tableName=0x2092c9718069 <String[6]: trades>,options=0xda400df1619 <an Object with map 0x7aefbdd3d61>)
    3: /* anonymo...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: node::Abort() [/home/axetroy/.nvm/versions/node/v6.11.0/bin/node]
 2: 0x109bf8c [/home/axetroy/.nvm/versions/node/v6.11.0/bin/node]
 3: v8::Utils::ReportApiFailure(char const*, char const*) [/home/axetroy/.nvm/versions/node/v6.11.0/bin/node]
 4: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [/home/axetroy/.nvm/versions/node/v6.11.0/bin/node]
 5: v8::internal::Factory::NewCode(v8::internal::CodeDesc const&, unsigned int, v8::internal::Handle<v8::internal::Object>, bool, bool, int, bool) [/home/axetroy/.nvm/versions/node/v6.11.0/bin/node]
 6: v8::internal::CodeGenerator::MakeCodeEpilogue(v8::internal::MacroAssembler*, v8::internal::CompilationInfo*) [/home/axetroy/.nvm/versions/node/v6.11.0/bin/node]
 7: v8::internal::FullCodeGenerator::MakeCode(v8::internal::CompilationInfo*) [/home/axetroy/.nvm/versions/node/v6.11.0/bin/node]
 8: 0xb4c51e [/home/axetroy/.nvm/versions/node/v6.11.0/bin/node]
 9: 0xb4e900 [/home/axetroy/.nvm/versions/node/v6.11.0/bin/node]
10: 0xb55fc6 [/home/axetroy/.nvm/versions/node/v6.11.0/bin/node]
11: v8::internal::Compiler::Compile(v8::internal::Handle<v8::internal::JSFunction>, v8::internal::Compiler::ClearExceptionFlag) [/home/axetroy/.nvm/versions/node/v6.11.0/bin/node]
12: v8::internal::Runtime_CompileLazy(int, v8::internal::Object**, v8::internal::Isolate*) [/home/axetroy/.nvm/versions/node/v6.11.0/bin/node]
13: 0x20d270b092a7
Aborted (core dumped)

Dialect: postgres Database version: 9.4 Sequelize version: 4.8.0

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
yocontracommented, Nov 6, 2017

Also seeing this while doing a bunch of inserts/reads at the same time (1.7K/min)

<--- Last few GCs --->

[64105:0x103000000]  1088377 ms: Mark-sweep 1406.1 (2129.5) -> 1406.1 (2129.5) MB, 326.9 / 0.0 ms  allocation failure GC in old space requested
[64105:0x103000000]  1088769 ms: Mark-sweep 1406.1 (2129.5) -> 1406.1 (2126.5) MB, 391.6 / 0.0 ms  last resort GC in old space requested
[64105:0x103000000]  1089121 ms: Mark-sweep 1406.1 (2126.5) -> 1406.1 (2126.5) MB, 351.4 / 0.0 ms  last resort GC in old space requested


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x2c8b81025ec1 <JSObject>
    0: builtin exit frame: Function(aka Function)(this=0x2c8bd9802311 <undefined>,0x2c8b529ff439 <String[674]\: \nthis['id'] = rowData[0] == null ? null : parsers[0](rowData[0]);\nthis['schema.id'] = rowData[1] == null ? null : parsers[1](rowData[1]);\nthis['schema.userId'] = rowData[2] == null ? null : parsers[2](rowData[2]);\nthis['schema.createdAt'] = rowData[3] == null ? null : parsers[3](ro...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: node::Abort() [/Users/contra/.nvm/versions/node/v8.9.0/bin/node]
 2: node::FatalException(v8::Isolate*, v8::Local<v8::Value>, v8::Local<v8::Message>) [/Users/contra/.nvm/versions/node/v8.9.0/bin/node]
 3: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [/Users/contra/.nvm/versions/node/v8.9.0/bin/node]
 4: v8::internal::Factory::NewFixedArray(int, v8::internal::PretenureFlag) [/Users/contra/.nvm/versions/node/v8.9.0/bin/node]
 5: v8::internal::HashTable<v8::internal::StringTable, v8::internal::StringTableShape>::EnsureCapacity(v8::internal::Handle<v8::internal::StringTable>, int, v8::internal::PretenureFlag) [/Users/contra/.nvm/versions/node/v8.9.0/bin/node]
 6: v8::internal::StringTable::LookupKey(v8::internal::Isolate*, v8::internal::StringTableKey*) [/Users/contra/.nvm/versions/node/v8.9.0/bin/node]
 7: v8::internal::AstValueFactory::Internalize(v8::internal::Isolate*) [/Users/contra/.nvm/versions/node/v8.9.0/bin/node]
 8: v8::internal::parsing::ParseProgram(v8::internal::ParseInfo*, v8::internal::Isolate*, bool) [/Users/contra/.nvm/versions/node/v8.9.0/bin/node]
 9: v8::internal::(anonymous namespace)::CompileToplevel(v8::internal::CompilationInfo*) [/Users/contra/.nvm/versions/node/v8.9.0/bin/node]
10: v8::internal::Compiler::GetFunctionFromEval(v8::internal::Handle<v8::internal::String>, v8::internal::Handle<v8::internal::SharedFunctionInfo>, v8::internal::Handle<v8::internal::Context>, v8::internal::LanguageMode, v8::internal::ParseRestriction, int, int, int, int, int, v8::internal::Handle<v8::internal::Object>, v8::ScriptOriginOptions) [/Users/contra/.nvm/versions/node/v8.9.0/bin/node]
11: v8::internal::Compiler::GetFunctionFromString(v8::internal::Handle<v8::internal::Context>, v8::internal::Handle<v8::internal::String>, v8::internal::ParseRestriction, int) [/Users/contra/.nvm/versions/node/v8.9.0/bin/node]
12: v8::internal::(anonymous namespace)::CreateDynamicFunction(v8::internal::Isolate*, v8::internal::BuiltinArguments, char const*) [/Users/contra/.nvm/versions/node/v8.9.0/bin/node]
13: v8::internal::Builtin_FunctionConstructor(int, v8::internal::Object**, v8::internal::Isolate*) [/Users/contra/.nvm/versions/node/v8.9.0/bin/node]
14: 0x268b0fc0441d
15: 0x268b0fe55070
16: 0x268b0fcf45fc

Node 8.9, latest sequelize.

Looks like to parse the result from PG it is creating a function - basically it makes so many that never get cleaned up and eventually runs the process out of memory.

I’m pretty sure the function from this stack is https://github.com/brianc/node-postgres/blob/884e21e1ca58b7045c94d8cef4941eb97ac50ed5/lib/result.js#L55 based on searching, but can’t be 100%.

1reaction
joshua-foggcommented, Apr 5, 2018

Had a similar problem but found that it was due to not having running the transactions in an async manner

Read more comments on GitHub >

github_iconTop Results From Across the Web

Memory leak - Wikipedia
In computer science, a memory leak is a type of resource leak that occurs when a computer program incorrectly manages memory allocations in...
Read more >
How do I check for memory leaks, and what should I do to stop ...
Tracking down a memory leak can be a difficult process. Let's say a program runs for a brief amount of time and has...
Read more >
What Is a Memory Leak and How Do They Happen?
A memory leak is one of the major causes of the slowing down of a computer. It can be dangerous and lead to...
Read more >
Memory leaks in Windows 10/11 - Stellar Data Recovery
System low on memory? It could be a memory leak! Read this guide to know what it is and how to avoid memory...
Read more >
How To Detect and Prevent Memory Leaks | Scout APM Blog
Multiple references: When the same object is referenced from multiple objects, it might lead to a memory leak when one of the references...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found