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

Allocation failed - JavaScript heap out of memory #71

Open
MuhammadSawalhy opened this issue Mar 24, 2021 · 7 comments
Open

Allocation failed - JavaScript heap out of memory #71

MuhammadSawalhy opened this issue Mar 24, 2021 · 7 comments

Comments

@MuhammadSawalhy
Copy link

MuhammadSawalhy commented Mar 24, 2021

Reproduce

svg-term --cast 47HiIPl0HQxrJ0R0vR9qpxzS4 --window --out animating-my-name.svg

Description

After running this command, my computer was noticeably slow, my mouse was not reponding sometimes. I quickly tried to run htop command in Linux:

Screenshot from 2021-03-24 22-34-22

After waiting a while, Nodejs logged these lines:

<--- Last few GCs --->

[313356:0x513b270]    89040 ms: Scavenge 1892.2 (2064.9) -> 1879.9 (2064.9) MB, 6.7 / 0.0 ms  (average mu = 0.255, current mu = 0.145) allocation failure 
[313356:0x513b270]    89205 ms: Scavenge 1896.4 (2064.9) -> 1886.5 (2067.6) MB, 24.6 / 0.0 ms  (average mu = 0.255, current mu = 0.145) allocation failure 
[313356:0x513b270]    90199 ms: Mark-sweep 1904.1 (2067.6) -> 1880.2 (2068.9) MB, 878.9 / 0.0 ms  (average mu = 0.299, current mu = 0.342) allocation failure scavenge might not succeed


<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 0xa04200 node::Abort() [svg-term]
 2: 0x94e4e9 node::FatalError(char const*, char const*) [svg-term]
 3: 0xb7978e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [svg-term]
 4: 0xb79b07 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [svg-term]
 5: 0xd34395  [svg-term]
 6: 0xd34f1f  [svg-term]
 7: 0xd42fab v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [svg-term]
 8: 0xd46b6c v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [svg-term]
 9: 0xd1524b v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [svg-term]
10: 0x105b23f v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [svg-term]
11: 0x1401219  [svg-term]
@christos-h
Copy link

@MuhammadSawalhy Just ran into this. It turns out the Node runtime is running out of memory (I think the default is 500mb or something). Depending on how much memory you have on your machine, you can increase this by setting environment variables. For a 4GB heap you can do this for example:

NODE_OPTIONS=--max-old-space-size=4096 svg-term --cast=236096 --out examples/parrot.svg --window

I can see that you were already close to the limit of your mem utilisation. The next time you run a conversion you may want to close all other windows and increase the size of your swap.

Good luck.

@cjbrigato
Copy link

Having memory issues doesn't always mean "lacking memory".
A good starting point to actually solve these issues is to understand that what lacks here is more about wishes to optimize and deliver quality software than memory.

"The next time you run a conversion you may want to close all other windows and increase the size of your swap."

I'll try that on our headless server farm, thanks.

@MuhammadSawalhy
Copy link
Author

wishes to optimize and deliver quality software than memory

This is the purpose of the issue 😅

@cjbrigato
Copy link

Indeed, but as expected it was not understood in proper way. Hence my addition ;)

@christos-h
Copy link

christos-h commented Aug 18, 2021

A good starting point to actually solve these issues is to understand that what lacks here is more about wishes to optimize and deliver quality software than memory.

Of course you're right. I was merely trying to offer pointers to individuals who arrived here by googling an error, and just want to get the job done without necessarily having the time to address the underlying issues.

@cjbrigato
Copy link

We tried converting a 1:30 asciinema with SVG term giving more than 4gb of ram available. It just killed the machine up to no responsiveness and needed reset.
In the meanwhile, https://github.com/nbedos/termtosvg just rendered the asciicast in under 5 sec flawlessly with under 200mb of ram.

The difference is so huge and the answer was so out of the scope that I first thought your answer was a joke. Definitely thought it was when I read the last sentence.

If it was not, then sorry, I never meant to talk about optimization seriously on a node-js software.

@helmut-messerer
Copy link

helmut-messerer commented Aug 3, 2023

see socketio/socket.io#3477 (comment)
try install libjemalloc and use
LD_PRELOAD=/path/to/libjemalloc.so
before launching javascript with node

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants