From 1f2c8b4ce7198e3f90c0324eefd46ea19ad7abef Mon Sep 17 00:00:00 2001 From: mizdra Date: Thu, 14 Mar 2024 11:07:41 +0900 Subject: [PATCH 1/2] doc: add how to free memory --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 78953341..ed02afdf 100755 --- a/README.md +++ b/README.md @@ -192,6 +192,8 @@ This package also ships a pure WebAssembly artifact built with `wasm-bindgen` to const resvgJS = new resvg.Resvg(svg, opts) const pngData = resvgJS.render(svg, opts) // Output PNG data, Uint8Array const pngBuffer = pngData.asPng() + pngData.free() // Free memory + resvgJS.free() const svgURL = URL.createObjectURL(new Blob([pngData], { type: 'image/png' })) document.getElementById('output').src = svgURL })() From 7714471b87908e82913cf50a83ac4217905b1459 Mon Sep 17 00:00:00 2001 From: mizdra Date: Thu, 14 Mar 2024 11:09:08 +0900 Subject: [PATCH 2/2] fix(playground): fix memory leak --- wasm/index.html | 3 +++ 1 file changed, 3 insertions(+) diff --git a/wasm/index.html b/wasm/index.html index 35471f86..d519f4e5 100644 --- a/wasm/index.html +++ b/wasm/index.html @@ -320,6 +320,9 @@ const pngData = resvgJS.render() const pngBuffer = pngData.asPng() + pngData.free() + resvgJS.free() + document.querySelector('#output img').src = URL.createObjectURL( new Blob([pngBuffer], { type: 'image/png' }) )