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

out of memory in getImageData #1749

Closed
goldenjayr opened this issue Feb 26, 2021 · 1 comment
Closed

out of memory in getImageData #1749

goldenjayr opened this issue Feb 26, 2021 · 1 comment

Comments

@goldenjayr
Copy link

goldenjayr commented Feb 26, 2021

I have a nodejs application that transforms images. I run my application with 32gb of ram. When trying to get the image data of a large image with more or less has a width of 20k and height of 20k I am getting this error. I have tried to increase the node js memory limit using --max-old-space-size tried to increase it to 8192 as well as 32678 but it I still get an error.

m[9161:0x41069d0] 18179 ms: Mark-sweep 22.3 (29.2) -> 22.0 (25.2) MB, 23.0 / 0.0 ms (+ 1.5 ms in 5 steps since start of marking, biggest step 0.8 ms, walltime since start of marking 55 ms) (average mu = 0.998, current mu = 0.963) finalize incremental m[9161:0x41069d0] 27013 ms: Mark-sweep 23.2 (25.2) -> 22.2 (25.2) MB, 3.8 / 0.0 ms (+ 0.1 ms in 2 steps since start of marking, biggest step 0.1 ms, walltime since start of marking 168 ms) (average mu = 0.999, current mu = 1.000) finalize incremental m

`<--- JS stacktrace --->

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

Security context: 0x21639e1c08d1
0: builtin exit frame: getImageData(this=0x0529133cc801 ,32150,22958,0,0,0x0529133cc801 )

1: getPoints [0x324589ad9b31] [/var/apps/print-export-worker/getPoints.js:11] [bytecode=0x340f496a0d29 offset=86](this=0x2d04988cd319 <JSGlobal Object>,0x0529133cc801 <CanvasRenderingContext2D map = 0x381c...

FATAL ERROR: v8::ArrayBuffer::New Allocation failed - process out of memory
1: 0xa09830 node::Abort() [node]
2: 0xa09c55 node::OnFatalError(char const*, char const*) [node]
3: 0xb7d71e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]
4: 0xb7da99 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]
5: 0xb7db7b [node]
6: 0xb9b93e [node]
7: 0x7f7f87de455f Context2d::GetImageData(Nan::FunctionCallbackInfov8::Value const&) [/var/apps/print-export-worker/node_modules/canvas/build/Release/canvas.node]
8: 0x7f7f87dd91f9 [/var/apps/print-export-worker/node_modules/canvas/build/Release/canvas.node]
9: 0xbe96a9 [node]
10: 0xbeb497 v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*) [node]
11: 0x13c5c79 [node]
Aborted`

I think that it's the limit of V8 to store an array bigger than its limit but how do I fix this problem.

@zbjornson
Copy link
Collaborator

ArrayBuffers are allocated off of the heap, so setting --max-old-space-size will have no impact. (Try node --max-old-space-size=50 -e "new Uint8Array(550000000).fill(1)" to see for yourself.) Are you calling getImageData in a loop? If so, there's like something retaining those buffers causing a leak.

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

No branches or pull requests

2 participants