Hi there,
I am using xlsx (https://www.npmjs.com/package/xlsx) in order to parse a large .xls file (about 1Mb).
I was able to do that previously in a lambda, and I’m trying to migrate everything to serverless.
I am using serverless-offline with serverless-webpack to transpile from ES6 with async await to node 6.
However, it seems that I have a “Javascript heap out of memory”…
I also tried to increase the memory by running like this:
node --max-old-space-size=12000 ./node_modules/serverless/bin/serverless webpack invoke -f import -p src/functions/import/event.json
It does not change anything. Did anyone already encountered the same issue? What can I do?
Thanks
Here is the stacktrace:
<--- Last few GCs --->
34509 ms: Mark-sweep 1341.7 (1395.0) -> 986.9 (1040.1) MB, 319.9 / 0 ms [allocation failure] [GC in old space requested].
35147 ms: Mark-sweep 986.9 (1040.1) -> 986.9 (1040.1) MB, 638.4 / 0 ms [allocation failure] [GC in old space requested].
35638 ms: Mark-sweep 986.9 (1040.1) -> 986.5 (1034.1) MB, 491.2 / 0 ms [last resort gc].
35934 ms: Mark-sweep 986.5 (1034.1) -> 986.5 (1033.1) MB, 295.2 / 0 ms [last resort gc].
<--- JS stacktrace --->
==== JS stack trace =========================================
Security context: 0x1a600d2c9e31 <JS Object>
2: make_sector_list [/Users/myuser/path/to/my/pkg/node_modules/xlsx/xlsx.js:~1259] [pc=0x32a8c9e4023c] (this=0x1a600d2e15d9 <JS Global Object>,sectors=0x330c67670d29 <JS Array[417]>,dir_start=414,fat_addrs=0x330c67670d09 <JS Array[4]>,ssz=512)
3: parse [/Users/myuser/path/to/my/pkg/node_modules/xlsx/xlsx.js:1090] [pc=0x32...
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
1: node::Abort() [/Users/myuser/.nvm/versions/node/v6.3.1/bin/node]
2: node::FatalException(v8::Isolate*, v8::Local<v8::Value>, v8::Local<v8::Message>) [/Users/myuser/.nvm/versions/node/v6.3.1/bin/node]
3: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [/Users/myuser/.nvm/versions/node/v6.3.1/bin/node]
4: v8::internal::Factory::NewUninitializedFixedArray(int) [/Users/myuser/.nvm/versions/node/v6.3.1/bin/node]
5: v8::internal::(anonymous namespace)::ElementsAccessorBase<v8::internal::(anonymous namespace)::FastPackedObjectElementsAccessor, v8::internal::(anonymous namespace)::ElementsKindTraits<(v8::internal::ElementsKind)2> >::ConvertElementsWithCapacity(v8::internal::Handle<v8::internal::JSObject>, v8::internal::Handle<v8::internal::FixedArrayBase>, v8::internal::ElementsKind, unsigned int, unsigned int, unsigned int, int) [/Usmyuseruser/.nvm/versions/node/v6.3.1/bin/node]
6: v8::internal::(anonymous namespace)::ElementsAccessorBase<v8::internal::(anonymous namespace)::FastPackedObjectElementsAccessor, v8::internal::(anonymous namespace)::ElementsKindTraits<(v8::internal::ElementsKind)2> >::GrowCapacityAndConvertImpl(v8::internal::Handle<v8::internal::JSObject>, unsigned int) myusers/myuser/.nvm/versions/node/v6.3.1/bin/node]
7: v8::internal::Runtime_GrowArrayElements(int, v8::internal::Object**, v8::internal::Isolate*) [/Users/myuser/.nvm/versions/node/v6.3.1/bin/node]
8: 0x32a8c8806338
[1] 9066 abort serverless webpack invoke -f import -p src/functions/import/event.json