使用node.js解析大型xml 500M

vik*_*vik 3 xml sax node.js

我正在使用isaacs的SAX来解析一个巨大的xml文件.也是La Gentz推荐的.

该过程使用大约650M的内存,我该如何减少这个或允许节点使用更多.

FATAL ERROR: CALL_AND_RETRY_0 Allocation failed - process out of memory
Run Code Online (Sandbox Code Playgroud)

我的XML文件大于300M,可以增长到1GB.

fen*_*ent 8

您应该将文件流式传输到解析器中,毕竟这就是流解析器的重点.

var parser = require('sax').createStream(strict, options);
fs.createReadStream(file).pipe(parser);
Run Code Online (Sandbox Code Playgroud)