Proxies permanently leak memory
See original GitHub issueEdit: see comments below for real issue (memory leak)
Objects returned by Comlink calls can’t be used for further calls. Example:
<!-- index.html -->
<!doctype html>
<script src="comlink.js"></script>
<script>
"use strict";
{
const worker = new Worker("worker.js");
const api = Comlink.proxy(worker);
async function start()
{
const app = await new api.App();
const ret = await app.getObject();
await ret.log(); // error
}
start();
}
</script>
// worker.js
"use strict";
importScripts("comlink.js");
class ReturnedObject {
log()
{
console.log("ReturnedObject log() method");
}
}
class App {
getObject()
{
return new ReturnedObject();
}
}
Comlink.expose({App, ReturnedObject}, self);
In index.html, the call to await ret.log()
throws TypeError: ret.log is not a function
. ret
has become an empty object (i.e. {}
) which seems to be because it got posted raw. This appears to prevent using comlink with APIs that return other objects, which is quite a severe limit on the complexity of APIs that can be used.
I would be super interested if you figure out a way to fix this without leaking memory, since it’s the same problem that is blocking via.js being usable in production.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:12
Top Results From Across the Web
Configuring the memory leak policy - IBM
When a classloader memory leak is detected, WebSphere® Application Server notifies you with informational messages in the log and by taking ...
Read more >Memory leak inside Castle - Google Groups
When "container.Kernel.ReleaseComponent(controller)" is called, this controller is not disposed and remains in memory forever - it introduce memory leak. The ...
Read more >Weakmap memory leak - javascript - Stack Overflow
I'm setting as Weakmap keys ES6 Proxies, all with the same handlers. I've created a wrapper class that, in its constructor iterates the...
Read more >OEM Module Causing Memory Leak On+ APX (ASM Proxy ...
Resident memory of +APX process seems to be leaking; it is increasing slowly but steadily and is now over 1.1 GB. RSS_MEM_usage by...
Read more >Memory management - JavaScript - MDN Web Docs
In contrast, JavaScript automatically allocates memory when objects are created ... Circular references are a common cause of memory leaks.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for the amazing work, @AshleyScirra. I am talking to Chromies as well, so let’s all continue in the bug you opened.
Leaving this issue open until we have come to a conclusion/fix.
I implemented usage of the WeakRef proposal on a branch that takes care of propagating GC’ing of proxies to the worker. If you fancy, take a look: #469