Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JavaScript heap out of memory using tsx with node v20.0.0 #238

Closed
1 task
NinjaInShade opened this issue May 6, 2023 · 3 comments
Closed
1 task

JavaScript heap out of memory using tsx with node v20.0.0 #238

NinjaInShade opened this issue May 6, 2023 · 3 comments
Labels
bug Something isn't working outdated pending triage

Comments

@NinjaInShade
Copy link

NinjaInShade commented May 6, 2023

Bug description

Hi guys, I have noticed a strange issue where javascript runs out of memory. I noticed it started happening in my CLI script when I switched to TSX. I can confirm this is TSX as this happens if I just run tsx to get the REPL and wait about 10-15 seconds.
Stack trace if that helps at all:

<--- Last few GCs --->

[99980:0x7f23e43a11f0]       16 ms: Scavenge 4.8 (6.1) -> 4.4 (6.6) MB, 0.27 / 0.00 ms  (average mu = 1.000, current mu = 1.000) allocation failure; 
[99980:0x7f23e43a11f0]       26 ms: Scavenge 5.9 (7.1) -> 5.6 (9.8) MB, 0.40 / 0.00 ms  (average mu = 1.000, current mu = 1.000) allocation failure; 
[99980:0x7f23e43a11f0]       46 ms: Scavenge 9.3 (11.6) -> 8.4 (11.6) MB, 0.99 / 0.00 ms  (average mu = 1.000, current mu = 1.000) allocation failure; 


<--- JS stacktrace --->

FATAL ERROR: NewSpace::EnsureCurrentCapacity Allocation failed - JavaScript heap out of memory

<--- Last few GCs --->

[99980:0x7f23e0527fe0]        9 ms: Scavenge 3.7 (5.1) -> 3.1 (5.3) MB, 0.22 / 0.00 ms  (average mu = 1.000, current mu = 1.000) allocation failure; 
[99980:0x7f23e0527fe0]       14 ms: Scavenge 4.8 (6.1) -> 4.4 (6.6) MB, 0.31 / 0.00 ms  (average mu = 1.000, current mu = 1.000) allocation failure; 


<--- JS stacktrace --->

FATAL ERROR: NewSpace::EnsureCurrentCapacity Allocation failed - JavaScript heap out of memory
 1: 0xc7d530 node::Abort() [/home/leon/.nvm/versions/node/v20.0.0/bin/node]
 2: 0xb638e8  [/home/leon/.nvm/versions/node/v20.0.0/bin/node]
 1: 0xc7d530 node::Abort() [/home/leon/.nvm/versions/node/v20.0.0/bin/node]
 3: 0xe8ee70 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [/home/leon/.nvm/versions/node/v20.0.0/bin/node]
 2: 0xb638e8  [/home/leon/.nvm/versions/node/v20.0.0/bin/node]
 4: 0xe8f157 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [/home/leon/.nvm/versions/node/v20.0.0/bin/node]
 3: 0xe8ee70 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [/home/leon/.nvm/versions/node/v20.0.0/bin/node]
 5: 0x10a07c5  [/home/leon/.nvm/versions/node/v20.0.0/bin/node]
 4: 0xe8f157 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [/home/leon/.nvm/versions/node/v20.0.0/bin/node]
 6: 0x10dfad9  [/home/leon/.nvm/versions/node/v20.0.0/bin/node]
 5: 0x10a07c5  [/home/leon/.nvm/versions/node/v20.0.0/bin/node]
 7: 0x10b2916 v8::internal::Heap::MarkCompact() [/home/leon/.nvm/versions/node/v20.0.0/bin/node]
 6: 0x10dfad9  [/home/leon/.nvm/versions/node/v20.0.0/bin/node]
 8: 0x10b7f6d v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::internal::GarbageCollectionReason, char const*) [/home/leon/.nvm/versions/node/v20.0.0/bin/node]
 7: 0x10b2916 v8::internal::Heap::MarkCompact() [/home/leon/.nvm/versions/node/v20.0.0/bin/node]
 9: 0x10b845c v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/home/leon/.nvm/versions/node/v20.0.0/bin/node]
 8: 0x10b7f6d v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::internal::GarbageCollectionReason, char const*) [/home/leon/.nvm/versions/node/v20.0.0/bin/node]
10: 0x10b8ff7 v8::internal::Heap::CollectGarbageForBackground(v8::internal::LocalHeap*) [/home/leon/.nvm/versions/node/v20.0.0/bin/node]
 9: 0x10b845c v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/home/leon/.nvm/versions/node/v20.0.0/bin/node]
11: 0x106c19c v8::internal::Factory::AllocateRaw(int, v8::internal::AllocationType, v8::internal::AllocationAlignment) [/home/leon/.nvm/versions/node/v20.0.0/bin/node]
10: 0x108e761 v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/home/leon/.nvm/versions/node/v20.0.0/bin/node]
12: 0x105da34 v8::internal::FactoryBase<v8::internal::Factory>::AllocateRawWithImmortalMap(int, v8::internal::AllocationType, v8::internal::Map, v8::internal::AllocationAlignment) [/home/leon/.nvm/versions/node/v20.0.0/bin/node]
11: 0x108f8f5 v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/home/leon/.nvm/versions/node/v20.0.0/bin/node]
13: 0x105fd35 v8::internal::FactoryBase<v8::internal::Factory>::AllocateRawOneByteInternalizedString(int, unsigned int) [/home/leon/.nvm/versions/node/v20.0.0/bin/node]
12: 0x150159a v8::internal::Heap::AllocateRawOrFail(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/home/leon/.nvm/versions/node/v20.0.0/bin/node]
14: 0x105fde2 v8::internal::FactoryBase<v8::internal::Factory>::NewOneByteInternalizedString(v8::base::Vector<unsigned char const> const&, unsigned int) [/home/leon/.nvm/versions/node/v20.0.0/bin/node]
13: 0x1502862 v8::internal::Deserializer<v8::internal::Isolate>::Allocate(v8::internal::AllocationType, int, v8::internal::AllocationAlignment) [/home/leon/.nvm/versions/node/v20.0.0/bin/node]
15: 0x13a5b60 v8::internal::Handle<v8::internal::String> v8::internal::StringTable::LookupKey<v8::internal::SequentialStringKey<unsigned char>, v8::internal::Isolate>(v8::internal::Isolate*, v8::internal::SequentialStringKey<unsigned char>*) [/home/leon/.nvm/versions/node/v20.0.0/bin/node]
14: 0x1505e39 v8::internal::Deserializer<v8::internal::Isolate>::ReadObject(v8::internal::SnapshotSpace) [/home/leon/.nvm/versions/node/v20.0.0/bin/node]
16: 0xec18ec void v8::internal::AstRawString::Internalize<v8::internal::Isolate>(v8::internal::Isolate*) [/home/leon/.nvm/versions/node/v20.0.0/bin/node]
15: 0x1504adb int v8::internal::Deserializer<v8::internal::Isolate>::ReadSingleBytecodeData<v8::internal::SlotAccessorForHeapObject>(unsigned char, v8::internal::SlotAccessorForHeapObject) [/home/leon/.nvm/versions/node/v20.0.0/bin/node]
17: 0xec20de void v8::internal::AstValueFactory::Internalize<v8::internal::Isolate>(v8::internal::Isolate*) [/home/leon/.nvm/versions/node/v20.0.0/bin/node]
16: 0x1505c11 v8::internal::Deserializer<v8::internal::Isolate>::ReadData(v8::internal::Handle<v8::internal::HeapObject>, int, int) [/home/leon/.nvm/versions/node/v20.0.0/bin/node]
18: 0x13d1066 void v8::internal::Parser::PostProcessParseResult<v8::internal::Isolate>(v8::internal::Isolate*, v8::internal::ParseInfo*, v8::internal::FunctionLiteral*) [/home/leon/.nvm/versions/node/v20.0.0/bin/node]
17: 0x1505ed8 v8::internal::Deserializer<v8::internal::Isolate>::ReadObject(v8::internal::SnapshotSpace) [/home/leon/.nvm/versions/node/v20.0.0/bin/node]
19: 0x13fa19e v8::internal::Parser::ParseFunction(v8::internal::Isolate*, v8::internal::ParseInfo*, v8::internal::Handle<v8::internal::SharedFunctionInfo>) [/home/leon/.nvm/versions/node/v20.0.0/bin/node]
18: 0x1504adb int v8::internal::Deserializer<v8::internal::Isolate>::ReadSingleBytecodeData<v8::internal::SlotAccessorForHeapObject>(unsigned char, v8::internal::SlotAccessorForHeapObject) [/home/leon/.nvm/versions/node/v20.0.0/bin/node]
20: 0x14004d1 v8::internal::parsing::ParseFunction(v8::internal::ParseInfo*, v8::internal::Handle<v8::internal::SharedFunctionInfo>, v8::internal::Isolate*, v8::internal::parsing::ReportStatisticsMode) [/home/leon/.nvm/versions/node/v20.0.0/bin/node]
19: 0x1505c11 v8::internal::Deserializer<v8::internal::Isolate>::ReadData(v8::internal::Handle<v8::internal::HeapObject>, int, int) [/home/leon/.nvm/versions/node/v20.0.0/bin/node]
21: 0xf5aefc v8::internal::Compiler::Compile(v8::internal::Isolate*, v8::internal::Handle<v8::internal::SharedFunctionInfo>, v8::internal::Compiler::ClearExceptionFlag, v8::internal::IsCompiledScope*, v8::internal::CreateSourcePositions) [/home/leon/.nvm/versions/node/v20.0.0/bin/node]
20: 0x1505ed8 v8::internal::Deserializer<v8::internal::Isolate>::ReadObject(v8::internal::SnapshotSpace) [/home/leon/.nvm/versions/node/v20.0.0/bin/node]
22: 0xf5b70e v8::internal::Compiler::Compile(v8::internal::Isolate*, v8::internal::Handle<v8::internal::JSFunction>, v8::internal::Compiler::ClearExceptionFlag, v8::internal::IsCompiledScope*) [/home/leon/.nvm/versions/node/v20.0.0/bin/node]
21: 0x1504adb int v8::internal::Deserializer<v8::internal::Isolate>::ReadSingleBytecodeData<v8::internal::SlotAccessorForHeapObject>(unsigned char, v8::internal::SlotAccessorForHeapObject) [/home/leon/.nvm/versions/node/v20.0.0/bin/node]
23: 0x14bdb7a v8::internal::Runtime_CompileLazy(int, unsigned long*, v8::internal::Isolate*) [/home/leon/.nvm/versions/node/v20.0.0/bin/node]
22: 0x1505c11 v8::internal::Deserializer<v8::internal::Isolate>::ReadData(v8::internal::Handle<v8::internal::HeapObject>, int, int) [/home/leon/.nvm/versions/node/v20.0.0/bin/node]
24: 0x18ffef6  [/home/leon/.nvm/versions/node/v20.0.0/bin/node]

Reproduction

  • Run tsx to get the REPL or on a file that stays open (e.g. with a timeout/promise)

Environment

- Node version 20.0.0
- Linux machine, for reference I am getting this on `Linux Mint 21 x86_64` with the `6.0.9-060009-generic` kernel.

  System:
    OS: Linux 6.0 Linux Mint 21 (Vanessa)
    CPU: (16) x64 AMD Ryzen 7 7700X 8-Core Processor
    Memory: 24.44 GB / 30.51 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 20.0.0 - ~/.nvm/versions/node/v20.0.0/bin/node
    npm: 9.6.5 - ~/.nvm/versions/node/v20.0.0/bin/npm

Can you work on a fix?

  • I’m interested in opening a pull request to address this issue.
@NinjaInShade NinjaInShade added bug Something isn't working pending triage labels May 6, 2023
@leeoniya
Copy link

leeoniya commented May 6, 2023

maybe nodejs/node#47566

@NinjaInShade
Copy link
Author

maybe nodejs/node#47566

I think you may be right. I just tried 20.1.0 and I'm not getting this anymore at all!

@privatenumber
Copy link
Owner

Closing as a duplicate of #229

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working outdated pending triage
Projects
None yet
Development

No branches or pull requests

3 participants