xml-js
xml-js copied to clipboard
FATAL ERROR: invalid table size Allocation failed - JavaScript heap out of memory
I tried to convert a ~20MB JSON object to XML. Any idea what's wrong and how to solve it?
xml-js version: 1.6.11 Node version: 8.0.12
I would appreciate any help/hint/guide/tips. Thanks!
<--- Last few GCs --->
[1575:0x3732900] 260 ms: Scavenge 12.5 (19.8) -> 10.4 (20.3) MB, 1.3 / 0.0 ms allocation failure
[1575:0x3732900] 362 ms: Scavenge 14.4 (21.3) -> 13.1 (23.3) MB, 1.4 / 0.0 ms allocation failure
[1575:0x3732900] 436 ms: Scavenge 16.5 (23.3) -> 14.5 (34.3) MB, 1.4 / 0.0 ms allocation failure
[1575:0x3732900] 645 ms: Scavenge 22.9 (34.3) -> 18.1 (34.8) MB, 1.2 / 0.0 ms allocation failure
<--- JS stacktrace --->
==== JS stack trace =========================================
Security context: 0xe07e4aa5879 <JSObject>
2: hasContentCompact [../node_modules/xml-js/lib/js2xml.js:208] [bytecode=0x2fcf364462e1 offset=9](this=0x18a93a20c2f1 <JSGlobal Object>,element=0x310d794f37c1 <Very long string[25474512]>,options=0x310d794f97e9 <Object map = 0x1c4c0e11ce51>,anyContent=0x28e6f22822d1 <undefined>)
3: arguments adaptor frame: 2->3
4: writeElementsCompact [...
FATAL ERROR: invalid table size Allocation failed - JavaScript heap out of memory
1: node::Abort() [node]
2: 0x8cbf4c [node]
3: v8::Utils::ReportOOMFailure(char const*, bool) [node]
4: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [node]
5: v8::internal::OrderedHashTable<v8::internal::OrderedHashSet, 1>::Allocate(v8::internal::Isolate*, int, v8::internal::PretenureFlag) [node]
6: v8::internal::OrderedHashTable<v8::internal::OrderedHashSet, 1>::Rehash(v8::internal::Handle<v8::internal::OrderedHashSet>, int) [node]
7: v8::internal::OrderedHashTable<v8::internal::OrderedHashSet, 1>::EnsureGrowable(v8::internal::Handle<v8::internal::OrderedHashSet>) [node]
8: v8::internal::OrderedHashSet::Add(v8::internal::Handle<v8::internal::OrderedHashSet>, v8::internal::Handle<v8::internal::Object>) [node]
9: v8::internal::KeyAccumulator::AddKey(v8::internal::Handle<v8::internal::Object>, v8::internal::AddKeyConversion) [node]
10: 0xd7d3ca [node]
11: v8::internal::KeyAccumulator::CollectOwnElementIndices(v8::internal::Handle<v8::internal::JSReceiver>, v8::internal::Handle<v8::internal::JSObject>) [node]
12: v8::internal::KeyAccumulator::CollectOwnKeys(v8::internal::Handle<v8::internal::JSReceiver>, v8::internal::Handle<v8::internal::JSObject>) [node]
13: v8::internal::KeyAccumulator::CollectKeys(v8::internal::Handle<v8::internal::JSReceiver>, v8::internal::Handle<v8::internal::JSReceiver>) [node]
14: v8::internal::FastKeyAccumulator::GetKeys(v8::internal::GetKeysConversion) [node]
15: 0x101eb24 [node]
16: v8::internal::Runtime_ForInPrepare(int, v8::internal::Object**, v8::internal::Isolate*) [node]
17: 0x10c9ce540d85
try export NODE_OPTIONS="--max-old-space-size=4096"
@larshp even 8192 does not work for me my file is too large any workaroud?
Encountering the same problem when converting XML file to JSON object. Increasing the heap size won't help, even for relatively small files (100MB). It feels like there is some bug or memory leak in this library.
I also take this exception when request a 700MB file from backend server. try command:node --max-old-space-size=8192 dist/main also take error. any workaroud for this issue?
We experience the same issue