JSONPatcherProxy
JSONPatcherProxy copied to clipboard
Memory leak
async function test()
{
const JSONPatcherProxy = (await import("jsonpatcherproxy")).JSONPatcherProxy
let gS = {
uno: {
},
}
let jsonPatcherProxy = new JSONPatcherProxy(gS)
let objc = jsonPatcherProxy.observe(true);
setInterval(() => {
let generate = jsonPatcherProxy.generate()
console.log("Generate", generate.length)
},500)
setInterval(() => {
for (let i = 0; i < 1000; i++)
objc.uno = { test: "test" }
},1)
}
test()
This library has a huge memory leak. Just run the above program and see memory usage increase until node is killed.
I remember there was a memory leak in the part using Map. It can be resolved by using WeakMap, like in this commit: https://github.com/argentumcode/JSONPatcherProxy/commit/43f7b2bc84a75b955fd323e259531f8e4128ff29
If the maintainer is okay with it, I can create a PR.