typeorm: Memory leak in postgres - crashes node

Issue type:

<--- Last few GCs --->
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
[29:0x4147350]  2796188 ms: Mark-sweep 1477.8 (1520.0) -> 1465.4 (1521.2) MB, 852.1 / 0.1 ms  (average mu = 0.253, current mu = 0.207) allocation failure scavenge might not succeed
[29:0x4147350]  2797191 ms: Mark-sweep 1479.0 (1521.5) -> 1463.4 (1521.2) MB, 806.5 / 0.1 ms  (average mu = 0.227, current mu = 0.197) allocation failure scavenge might not succeed
<--- JS stacktrace --->
==== JS stack trace =========================================
    0: ExitFrame [pc: 0x13cf019]
Security context: 0x340360a008d1 <JSObject>
    1: /* anonymous */(aka /* anonymous */) [0x1d76b52d04a1] [/app/node_modules/typeorm/query-builder/RelationIdLoader.js:~93] [pc=0x331c83d059b0](this=0x22e64c6804b1 <undefined>,0x0e9b400da2b9 <Object map = 0x2e6ef8dbe379>)
    2: forEach [0x340360a16769](this=0x26ad8b44e919 <JSArray[363]>,0x1d76b52d04a1 <JSFunction (sfi = 0x15f19a7b2f81)>)
    3: /* anonymous *...
 1: 0xa093f0 node::Abort() [/usr/local/bin/node]
 2: 0xa097fc node::OnFatalError(char const*, char const*) [/usr/local/bin/node]
 3: 0xb842ae v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
 4: 0xb84629 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
 5: 0xd30fe5  [/usr/local/bin/node]
 6: 0xd31676 v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [/usr/local/bin/node]
 7: 0xd3def5 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/usr/local/bin/node]
 8: 0xd3eda5 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/usr/local/bin/node]
 9: 0xd4185c v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/bin/node]
10: 0xd0830b v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/usr/local/bin/node]
11: 0x1049f4e v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/usr/local/bin/node]
12: 0x13cf019  [/usr/local/bin/node]
Aborted (core dumped)
error Command failed with exit code 134.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

[x] bug report [ ] feature request [ ] documentation issue

Database system/driver:

[ ] cordova [ ] mongodb [ ] mssql [ ] mysql / mariadb [ ] oracle [x] postgres [ ] cockroachdb [ ] sqlite [ ] sqljs [ ] react-native [ ] expo

TypeORM version:

[x] latest [ ] @next [ ] 0.x.x (or put your version here)

Steps to reproduce or a small repository showing the problem:

using pg & pg-native I am not 100% why it crashes but it’s doing 30 updates per second and 150 selects

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 4
  • Comments: 15 (7 by maintainers)

Most upvoted comments

After investigating, I found that there was no memory leak in my case. Just an astronomical amount of memory used that would probably be released if it didn’t crash due to memory limit exceeded.

Our reconciler for converting raw SQL back into entities could definitely use some attention.