"javascript Heap Out Of Memory" While Streaming Large File
I am trying to XML -> JSON -> MongoDB on my server. I have a NodeJS application which streams the XML, converts it into JSON, then adds it to the MongoDB server in chunks of
Solution 1:
Posting my comment as an answer, since it solved the issue and might be useful to others having difficulting using the xml-stream
package in this way.
In question, the collect
method is causing the issue as it is forcing the parser to collect all the instances of the processed node in an array as they are parsed. collect
should only be used to collect children items of a certain type from each node that is being parsed. The default behaviour is not to do that (due to the streaming nature of the parser that lets you process multi gigabyte files with ease).
So solution was to remove that line of code and just use the endElement
event.
Post a Comment for ""javascript Heap Out Of Memory" While Streaming Large File"