justinwilaby / sax-wasm

The first streamable, fixed memory XML, HTML, and JSX parser for WebAssembly.
MIT License
168 stars 8 forks source link

Resolves #55 - Parser fails on large files due to arithmetic overflow. #56

Closed justinwilaby closed 2 years ago

justinwilaby commented 2 years ago

Turns out there was a mem leak due to the use of mem::transmute for encoded data. This caused the WebAssembly.Memory to grow in proportion to the number of tags encountered in the document.

This has been fixed and verified with a 6.5gb XML document. Memory monitoring shows garbage collection on the JS thread is occurring around the 300mb mark.

A significant boost in parsing speed also resulted from this fix due to fewer allocations in memory.