Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upMemory leaks [META] #712
Memory leaks [META] #712
Comments
This comment has been minimized.
This comment has been minimized.
|
#551: |
This comment has been minimized.
This comment has been minimized.
|
If you do not unsubscribe peers that you remember all of them #248 |
This comment has been minimized.
This comment has been minimized.
|
I believe here is same problem |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
torrent-discovery |
This comment has been minimized.
This comment has been minimized.
|
Here is one more trick var MemoryLeak = function(){}
var Item = function(node) {
var self = this
this.node = node
window.addEventListener('resize', function resizeHandler() {
if (!self.node) {return}
self.node.textContent = 'window width: ' + window.width
})
}
Item.die = function() {
this.node = null
this.leak = new MemoryLeak()
}If your code fine than GC will remove whole |
This comment has been minimized.
This comment has been minimized.
|
So a simple way to make the code clean can be encapsulate event listeners calls with some kind of listener registry and call an 'unregister' function on destroy? |
This comment has been minimized.
This comment has been minimized.
|
@arestov Thanks for trying to get to the bottom of this. I just cleaned up the leak in |
This comment has been minimized.
This comment has been minimized.
|
I think I've finally fixed all the leaks. Huge PR coming soon. |
This comment has been minimized.
This comment has been minimized.
|
Although leaking memory seems to be fixed, an examination between the memory behavior of my macbook pro and rpi causes me a lot of confusion. It is my understanding that webtorrent-cli tries to download a file to RAM (and sometimes to the HD as well). At least this is what it seems to be doing when I launch it as On my MPB however, launching with |
This comment has been minimized.
This comment has been minimized.
|
@rien333 |
This comment has been minimized.
This comment has been minimized.
|
I am fairly sure this was just a bug in mpv for the Pi at one point. (the devs have been kinda neglicant of it so i think it could have been fairly specific). I think I eventually found out that the RAM filled up pretty fast while streaming basically anything. Anyway, It's fixed now. |
Webtorrent and its modules has a lot of code similar to this simple example, which is actually a good example of memory leak:
Using:
resizeHandler still in window resize events, it still has referrence to variable
self,yes we made
nodefree, butitemstuck in memory;To fix it we should not have closures in event listeners after
die:(you can imaging that
setTimeout(fn, 30000)and evenprocess.nextTick/setImmidiatewill be problem for GC too)