(Original question involving CGO was deleted and replaced with a simpler demonstration that shows what I think to be the core problem, the old question can still be accessed in the edit history.)
Use case: I am using the npm package ffi-napi to call a native function (nothing surprising).
Problem: each call, even of a void() function, leaks memory, which seems, well, a bit problematic.
Most simple repro I came up with:
const lib = ffi.Library(null, {
'atoi': ['int', ['string']]
});
let i = 0;
while (++i) {
lib.atoi('1234');
global.gc();
if (i % 100000 == 0) {
console.log(`iter. #${i} RSS MBs used: ${process.memoryUsage().rss / 1024 / 1024}`);
}
}
Outputs:
iter. #100000 RSS MBs used: 304.8359375
iter. #200000 RSS MBs used: 509.48828125
iter. #300000 RSS MBs used: 755.44140625
iter. #400000 RSS MBs used: 905.8203125
iter. #500000 RSS MBs used: 1123.90234375
iter. #600000 RSS MBs used: 1370.88671875
iter. #700000 RSS MBs used: 1612.45703125
-- CUT --
iter. #6200000 RSS MBs used: 11568.64453125
iter. #6300000 RSS MBs used: 11794.2109375
iter. #6400000 RSS MBs used: 11905.625
iter. #6500000 RSS MBs used: 12026.44921875
<--- Last few GCs --->
[1217086:0x5627be68a030] 168590 ms: Mark-sweep 2003.3 (2070.7) -> 1992.3 (2072.7) MB, 3546.0 / 170.8 ms (average mu = 0.101, current mu = 0.024) allocation failure scavenge might not succeed
[1217086:0x5627be68a030] 171579 ms: Mark-sweep 2005.6 (2072.7) -> 1994.6 (2074.7) MB, 2907.8 / 231.8 ms (average mu = 0.068, current mu = 0.027) allocation failure scavenge might not succeed
<--- JS stacktrace --->
==== JS stack trace =========================================
0: ExitFrame [pc: 0x7fe054be1679]
Security context: 0x146fda0db989 <JSObject>
1: debug [0x11881d6991b9] [/home/morgan/Documents/Code/nogame/node_modules/debug/src/common.js:~64] [pc=0x553685c70a5](this=0x036c76042a69 <JSGlobal Object>)
2: arguments adaptor frame: 1->0
3: ./apps/server/src/main.ts [0x1cd68b8fffa9] [/home/morgan/Documents/Code/nogame/dist/apps/server/main.js:~94] [pc=0x553685d6a90](this=0x23bff30191f9 <Objec...
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
1: 0x7fe053f2da9c node::Abort() [/lib/x86_64-linux-gnu/libnode.so.72]
2: 0x7fe053e61872 [/lib/x86_64-linux-gnu/libnode.so.72]
3: 0x7fe054107aea v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/lib/x86_64-linux-gnu/libnode.so.72]
4: 0x7fe054107dcb v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/lib/x86_64-linux-gnu/libnode.so.72]
5: 0x7fe0542b59b9 [/lib/x86_64-linux-gnu/libnode.so.72]
6: 0x7fe0542c5da7 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/lib/x86_64-linux-gnu/libnode.so.72]
7: 0x7fe0542c6a8f v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/lib/x86_64-linux-gnu/libnode.so.72]
8: 0x7fe0542c8d7c v8::internal::Heap::AllocateRawWithLightRetry(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/lib/x86_64-linux-gnu/libnode.so.72]
9: 0x7fe0542c8de8 v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/lib/x86_64-linux-gnu/libnode.so.72]
10: 0x7fe05428d7ef v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/lib/x86_64-linux-gnu/libnode.so.72]
11: 0x7fe0545df559 v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/lib/x86_64-linux-gnu/libnode.so.72]
12: 0x7fe054be1679 [/lib/x86_64-linux-gnu/libnode.so.72]
[1] 1217086 IOT instruction node --expose-gc dist/apps/server/main.js
NB: The same problem occurs with ffi-cross.
Valgrind log here for 5000 iterations: https://pastebin.com/p3Uv4WwR.
The leaking stack appears clearly:
==1223109== 400,160 bytes in 5,002 blocks are definitely lost in loss record 61 of 61
==1223109== at 0x4A3F723: operator new(unsigned long) (vg_replace_malloc.c:417)
==1223109== by 0x5428CE9: napi_create_reference (in /usr/lib/x86_64-linux-gnu/libnode.so.72)
==1223109== by 0xDACDEFF: (anonymous namespace)::InstanceData::GetBufferData(napi_value__*) (in /home/morgan/Documents/Code/redacted/node_modules/ref-napi/prebuilds/linux-x64/node.napi.node)
==1223109== by 0xDCE372F: FFI::FFI::FFICall(Napi::CallbackInfo const&) (in /home/morgan/Documents/Code/redacted/node_modules/ffi-napi/build/Release/ffi_bindings.node)
==1223109== by 0xDCE6B0D: Napi::details::CallbackData<void (*)(Napi::CallbackInfo const&), void>::Wrapper(napi_env__*, napi_callback_info__*) (in /home/morgan/Documents/Code/redacted/node_modules/ffi-napi/build/Release/ffi_bindings.node)
==1223109== by 0x5421127: ??? (in /usr/lib/x86_64-linux-gnu/libnode.so.72)
==1223109== by 0x56AFB48: v8::internal::FunctionCallbackArguments::Call(v8::internal::CallHandlerInfo) (in /usr/lib/x86_64-linux-gnu/libnode.so.72)
==1223109== by 0x56AFEF4: ??? (in /usr/lib/x86_64-linux-gnu/libnode.so.72)
==1223109== by 0x56B0749: ??? (in /usr/lib/x86_64-linux-gnu/libnode.so.72)
==1223109== by 0x56B101C: v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*) (in /usr/lib/x86_64-linux-gnu/libnode.so.72)
==1223109== by 0x6123778: ??? (in /usr/lib/x86_64-linux-gnu/libnode.so.72)
==1223109== by 0x60A8F03: ??? (in /usr/lib/x86_64-linux-gnu/libnode.so.72)
I will post an issue in the library's GitHub but any help would be greatly appreciated.
Related
So I was using my bot but since it didn't respond, I decided to check why it was offline. I opened up my code and I found this error in the console. I just wanna know what it means. Here :
<--- Last few GCs --->
[880:0x4b70e20] 26014144 ms: Mark-sweep 234.2 (257.5) -> 234.2 (257.8) MB, 2824.5 / 0.0 ms (average mu = 0.148, current mu = 0.008) allocation failure scavenge might not succeed
[880:0x4b70e20] 26017038 ms: Mark-sweep 234.6 (257.8) -> 234.5 (257.8) MB, 2888.0 / 0.0 ms (average mu = 0.081, current mu = 0.002) allocation failure scavenge might not succeed
<--- JS stacktrace --->
==== JS stack trace =========================================
Security context: 0x1f02f9e808d1 <JSObject>
0: builtin exit frame: parse(this=0x1f02f9e9ee79 <Object map = 0x1cdd4fa03639>,0x15196d9c0119 <Very long string[8081560]>,0x1f02f9e9ee79 <Object map = 0x1cdd4fa03639>)
1: onMessage [0x118b705220e9] [/home/runner/New-Neptune/node_modules/discord.js/src/client/websocket/WebSocketShard.js:~278] [pc=0x2bb58926f89e](this=0x3f8662a33761 <EventEmitter map = 0x2d550d1ce3a9>,0x1166c1f7f291 <Even...
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
1: 0xa1a640 node::Abort() [node]
2: 0xa1aa4c node::OnFatalError(char const*, char const*) [node]
3: 0xb9a68e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]
4: 0xb9aa09 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]
5: 0xd57c85 [node]
6: 0xd58316 v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [node]
7: 0xd64bd5 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [node]
8: 0xd65a85 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]
9: 0xd6853c v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]
10: 0xd363dc v8::internal::Factory::NewRawOneByteString(int, v8::internal::AllocationType) [node]
11: 0xe4561b v8::internal::JsonParser<unsigned short>::MakeString(v8::internal::JsonString const&, v8::internal::Handle<v8::internal::String>) [node]
12: 0xe47e9e v8::internal::JsonParser<unsigned short>::ParseJsonValue() [node]
13: 0xe486af v8::internal::JsonParser<unsigned short>::ParseJson() [node]
14: 0xc4bc05 v8::internal::Builtin_JsonParse(int, unsigned long*, v8::internal::Isolate*) [node]
15: 0x140df99 [node]
JavaScript heap out of memory
It ran out of memory.
Without seeing your code, it's impossible to say why in particular, but seeing Builtin_JsonParse in the stack means it was probably parsing a big JSON response from somewhere.
In my case, I was pre autopopulating my document with fields that reference see here its own model...When I tried to hit my API with new data it was working fine like in my case when I was logging in with new signup data it was working fine but with old login data, it was running an infinite loop due to autopopulate which further caused heap out of memory issue..I just realized when I turned on mongoose debugger....After removing those autopopulates my application is working fine
removing autopopulate
Then I removed these autopopulate statements from my code and now it's working fine
I am running a nodejs app on AWS ec2 instance(t2.small). After it works around one week. Below out of memory error comes. Searched for same issues, found there is a workaround to increase "--max-old-space-size" option. However, my question is
if i set --max-old-space-size = 4096(4gb). Do i need to update the aws instance to get more memory(as small type only have 2 gb memory)
This max-old-space-size setting,finally will it also hit memory limitation? At the beginning, the app is working fine, but after period of time, app is crushed. If that, how to slove this issue effectively?
The full error message as below:
<--- Last few GCs --->
[30600:0x5007800] 429029005 ms: Mark-sweep 977.8 (1007.7) -> 970.6 (1008.9) MB, 2379.3 / 0.5 ms (average mu = 0.220, current mu = 0.190) allocation failure scavenge might n
ot succeed
[30600:0x5007800] 429031937 ms: Mark-sweep 979.0 (1008.9) -> 971.8 (1010.4) MB, 2396.6 / 0.4 ms (average mu = 0.202, current mu = 0.183) allocation failure scavenge might n
ot succeed
<--- JS stacktrace --->
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
1: 0xa02ec0 node::Abort() [node]
2: 0x94e471 node::FatalError(char const*, char const*) [node]
3: 0xb765de v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]
4: 0xb76957 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]
5: 0xd311f5 [node]
6: 0xd31d7f [node]
7: 0xd3fe0b v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]
8: 0xd439cc v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [no
de]
9: 0xd120ab v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [node]
10: 0x105802f v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [node]
11: 0x13fdfd9 [node]
./backend.sh: line 6: 30600 Aborted node server.js
Thanks for all your help!
World
I'm developing mobile application using Nativescript, most latest version.
Android build is OK.
But iOS is pain in the back for me.
I'm constantly receiving heap overflow. Tried to set more heap memory for node...
Mac Mini with 8GB RAM.
Just upgraded do 16GB - no change.
nrtc63-99:zplapp nrtc63$ export | grep NODE
declare -x NODE_OPTIONS="--max_old_space_size=12192"
Tried also other values starting including 8192 and dashes --max-old-space-size.
Build log...
<--- Last few GCs --->
[1535:0x102d4e000] 314170 ms: Scavenge 4078.7 (4103.3) -> 4078.0 (4103.3) MB, 11.8 / 0.0 ms (average mu = 0.356, current mu = 0.326) allocation failure
[1535:0x102d4e000] 314179 ms: Scavenge 4078.9 (4103.3) -> 4078.2 (4103.5) MB, 9.0 / 0.0 ms (average mu = 0.356, current mu = 0.326) allocation failure
[1535:0x102d4e000] 316720 ms: Mark-sweep 4080.1 (4104.7) -> 4077.1 (4104.3) MB, 2537.7 / 0.0 ms (average mu = 0.318, current mu = 0.280) allocation failure scavenge might not succeed
<--- JS stacktrace --->
==== JS stack trace =========================================
0: ExitFrame [pc: 0x1009ce0f9]
Security context: 0x02b2663408d1 <JSObject>
1: SourceMapConsumer_allGeneratedPositionsFor [0x2b20af167f9] [/Users/nrtc63/WebstormProjects/zplapp/node_modules/#babel/core/node_modules/source-map/lib/source-map-consumer.js:~178] [pc=0xe56ee1564df](this=0x02b2a7e50051 <BasicSourceMapConsumer map = 0x2b2c76e1b39>,0x02b2b5295e01 <Object map = 0x2b2c76e1099>)
2: /* anonymous */(aka /* anonymous */) [0x...
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
1: 0x1011bdf85 node::Abort() (.cold.1) [/usr/local/bin/node]
2: 0x10009d119 node::Abort() [/usr/local/bin/node]
3: 0x10009d27f node::OnFatalError(char const*, char const*) [/usr/local/bin/node]
4: 0x1001de7b7 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
5: 0x1001de757 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
6: 0x100364225 v8::internal::Heap::FatalProcessOutOfMemory(char const*) [/usr/local/bin/node]
7: 0x100365a7a v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [/usr/local/bin/node]
8: 0x1003624fe v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/usr/local/bin/node]
9: 0x1003602b0 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/usr/local/bin/node]
10: 0x10036c0da v8::internal::Heap::AllocateRawWithLightRetry(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/bin/node]
11: 0x10036c161 v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/bin/node]
12: 0x10033a5ea v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/usr/local/bin/node]
13: 0x100689068 v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/usr/local/bin/node]
14: 0x1009ce0f9 Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_NoBuiltinExit [/usr/local/bin/node]
15: 0xe56ee1564df
16: 0x100953aa4 Builtins_InterpreterEntryTrampoline [/usr/local/bin/node]
17: 0x1009e01ec Builtins_ArrayForEach [/usr/local/bin/node]
Executing webpack failed with exit code null.
Memory utilisation for node process grows up to 4.3GB and then heap-overflow is raised.
The Error:
So I get something that looks like this:
<--- Last few GCs --->
[53206:0x104800000] 14400 ms: Mark-sweep 854.6 (956.2) -> 854.6 (916.7) MB, 47.2 / 0.0 ms (average mu = 0.871, current mu = 0.000) last resort GC in old space requested
[53206:0x104800000] 14445 ms: Mark-sweep 854.6 (916.7) -> 854.6 (915.2) MB, 44.3 / 0.0 ms (average mu = 0.754, current mu = 0.000) last resort GC in old space requested
<--- JS stacktrace --->
==== JS stack trace =========================================
0: ExitFrame [pc: 0x32ff55ecfc7d]
Security context: 0x04eea581d9b1 <JSObject>
1: byteLength(aka byteLength) [0x4ee3fcd6129] [buffer.js:522] [bytecode=0x4ee55266c61 offset=204](this=0x04ee450825b1 <undefined>,0x04ee72d252e1 <Very long string[433772571]>,0x04eea587f519 <String[4]: utf8>)
2: arguments adaptor frame: 3->2
3: fromString(aka fromString) [0x4ee3fcef989] [buffer.js:333] [bytecode=0x4ee552620b9 offset=77](this=0x04...
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
1: 0x1000645d3 node::Abort() [/usr/local/Cellar/node/11.12.0/bin/node]
2: 0x100064c5b node::OnFatalError(char const*, char const*) [/usr/local/Cellar/node/11.12.0/bin/node]
3: 0x10017e40f v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/usr/local/Cellar/node/11.12.0/bin/node]
4: 0x10017e3b0 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/usr/local/Cellar/node/11.12.0/bin/node]
5: 0x100440714 v8::internal::Heap::UpdateSurvivalStatistics(int) [/usr/local/Cellar/node/11.12.0/bin/node]
6: 0x10044681e v8::internal::Heap::SetUp() [/usr/local/Cellar/node/11.12.0/bin/node]
7: 0x1004269af v8::internal::Factory::AllocateRawWithImmortalMap(int, v8::internal::PretenureFlag, v8::internal::Map*, v8::internal::AllocationAlignment) [/usr/local/Cellar/node/11.12.0/bin/node]
8: 0x100428511 v8::internal::Factory::NewRawTwoByteString(int, v8::internal::PretenureFlag) [/usr/local/Cellar/node/11.12.0/bin/node]
9: 0x100505f5e v8::internal::String::SlowFlatten(v8::internal::Isolate*, v8::internal::Handle<v8::internal::ConsString>, v8::internal::PretenureFlag) [/usr/local/Cellar/node/11.12.0/bin/node]
10: 0x1001921f1 v8::String::Utf8Length(v8::Isolate*) const [/usr/local/Cellar/node/11.12.0/bin/node]
11: 0x10004cd13 node::Buffer::(anonymous namespace)::ByteLengthUtf8(v8::FunctionCallbackInfo<v8::Value> const&) [/usr/local/Cellar/node/11.12.0/bin/node]
12: 0x1001e2ac4 v8::internal::FunctionCallbackArguments::Call(v8::internal::CallHandlerInfo*) [/usr/local/Cellar/node/11.12.0/bin/node]
13: 0x1001e2124 v8::internal::MaybeHandle<v8::internal::Object> v8::internal::(anonymous namespace)::HandleApiCallHelper<false>(v8::internal::Isolate*, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::FunctionTemplateInfo>, v8::internal::Handle<v8::internal::Object>, v8::internal::BuiltinArguments) [/usr/local/Cellar/node/11.12.0/bin/node]
14: 0x1001e1944 v8::internal::Builtin_Impl_HandleApiCall(v8::internal::BuiltinArguments, v8::internal::Isolate*) [/usr/local/Cellar/node/11.12.0/bin/node]
15: 0x32ff55ecfc7d
and I have absolutely no idea how to even start debugging this. I've looked at similar questions "Javascript heap out of memory" and understand that I can increase the memory limit (which seams to be the most commonly suggested solution).
The Code
The function that is causing the error is an express controller looking something like this (simplified):
const foo = async (req,res) => {
// get users in chat room
const users = await db.getUsers(req.query.roomId);
res.send(users);
}
The error came when I added another user to the room. I've also checked that the error disappears if I filter out the last added user. From print-debugging I've also seen that all code executes up to the res.send statement so it seems the error is happening in that function.
The Question
The reason I'm hesitant at just adding more memory is that I'm just pushing the problem further away and instead of crashing at 6 users it will crash at 15 or 30 users.
So I would like to debug the script (perhaps see how much memory the users object takes up and how different forms of optimisations would affect that.
I simply don't know how to debug these kind of low level errors and wonder if there are some standard you can go through when encountering this kind of error?
PS: Just found it kinda funny that the top suggested similar question is:
How to create an HTML button that acts like a link?
I am running a NodeJS server and when it takes a large post request(>100mb), it fails due to heap out of memory.
I have tried setting --max-old-space-size=8000, but it didn't work at all even though I set it properly and checked that it is set to 8GB.
<--- Last few GCs --->
GC[20429:0x3851890] 12498 ms: Mark-sweep 400.5 (420.8) -> 316.5 (336.7) MB, 7.3 / 0.0 ms (+ 5.3 ms in 1 steps since start of marking, biggest step 5.3 ms, walltime since start of marking 1796 ms) (average mu = 0.991, current mu = 0.994) allocation failu[20429:0x3851890] 15081 ms: Mark-sweep 700.5 (720.8) -> 412.5 (432.7) MB, 114.6 / 0.0 ms (+ 0.0 ms in 0 steps since start of marking, biggest step 0.0 ms, walltime since start of marking 2583 ms) (average mu = 0.967, current mu = 0.956) allocation fai
<--- JS stacktrace --->
==== JS stack trace =========================================
0: ExitFrame [pc: 0x3ac05b24fc5d]
Security context: 0x3661c71546f1 <JSObject>
1: slice [0x3661c71409e9](this=0x0287971abf39 <Uint8Array map = 0x382c0352a4d1>,0)
2: md5 [0x14615e91adb1] [/home/minjae/Dev/mednick_minjae/mednick_api_minjae/node_modules/md5/md5.js:16] [bytecode=0x16b93054ad39 offset=106](this=0x1dac4a782371 <JSGlobal Object>,0x0287971abf39 <Uint8Array map = 0x382c0352a4d1>,0x2eaf18e825b1 <undefined>)
3: /* ano...
FATAL ERROR: invalid table size Allocation failed - JavaScript heap out of memory
1: 0x95bd00 node::Abort() [/usr/bin/node]
2: 0x95cc46 node::OnFatalError(char const*, char const*) [/usr/bin/node]
3: 0xb3dbde v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/usr/bin/node]
4: 0xb3de14 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/usr/bin/node]
5: 0xf3ce52 [/usr/bin/node]
6: 0x105f567 v8::internal::HashTable<v8::internal::NumberDictionary, v8::internal::NumberDictionaryShape>::New(v8::internal::Isolate*, int, v8::internal::PretenureFlag, v8::internal::MinimumCapacity) [/usr/bin/node]
7: 0x105fdcd v8::internal::HashTable<v8::internal::NumberDictionary, v8::internal::NumberDictionaryShape>::EnsureCapacity(v8::internal::Isolate*, v8::internal::Handle<v8::internal::NumberDictionary>, int, v8::internal::PretenureFlag) [/usr/bin/node]
8: 0x10607fb v8::internal::Dictionary<v8::internal::NumberDictionary, v8::internal::NumberDictionaryShape>::Add(v8::internal::Isolate*, v8::internal::Handle<v8::internal::NumberDictionary>, unsigned int, v8::internal::Handle<v8::internal::Object>, v8::internal::PropertyDetails, int*) [/usr/bin/node]
9: 0xec2cee [/usr/bin/node]
10: 0x105a3d4 v8::internal::JSObject::AddDataElement(v8::internal::Handle<v8::internal::JSObject>, unsigned int, v8::internal::Handle<v8::internal::Object>, v8::internal::PropertyAttributes) [/usr/bin/node]
11: 0x10738bb v8::internal::Object::AddDataProperty(v8::internal::LookupIterator*, v8::internal::Handle<v8::internal::Object>, v8::internal::PropertyAttributes, v8::internal::ShouldThrow, v8::internal::Object::StoreFromKeyed) [/usr/bin/node]
12: 0x107aec0 v8::internal::JSObject::DefineOwnPropertyIgnoreAttributes(v8::internal::LookupIterator*, v8::internal::Handle<v8::internal::Object>, v8::internal::PropertyAttributes, v8::internal::ShouldThrow, v8::internal::JSObject::AccessorInfoHandling) [/usr/bin/node]
13: 0x107e3f5 v8::internal::JSObject::CreateDataProperty(v8::internal::LookupIterator*, v8::internal::Handle<v8::internal::Object>, v8::internal::ShouldThrow) [/usr/bin/node]
14: 0x108ff18 v8::internal::JSReceiver::CreateDataProperty(v8::internal::LookupIterator*, v8::internal::Handle<v8::internal::Object>, v8::internal::ShouldThrow) [/usr/bin/node]
15: 0x11f6770 v8::internal::Runtime_CreateDataProperty(int, v8::internal::Object**, v8::internal::Isolate*) [/usr/bin/node]
16: 0x3ac05b24fc5d
Aborted
I firstly thought that there is a code causing error, taking much heap space. However, it prints error when it doesn't even get to my very first code. It seems to break when it is receiving the post request.
You can use streams to send request data in chunks (smaller parts). A good example is here. The example is for a file. However, if it is non-file data (e.g. text, JSON, XML), you can write it to a temp file, send that file to your server in chunks and have the server read the file, to retrieve data you sent, once all chunks are received.