mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-07 05:31:25 -07:00
Fix JS memory leak
The memory leak can be reproduced easily by opening two web pages of qbittorrent so that the WebUI pages are updated with full_update = true. If you have a large number of torrents, such as 100 torrents, you can observe a rapid increase in memory usage. This is caused by the incorrect usage of dispose and empty methods in the js codes and none of them garbage collect the elements. If event listeners are added to the DOM elements, those DOM elements will not be garbage collected at all event if they are not referenced or out of the scope, which will cause memory leaks. If some elements are expected to be removed, the correct way is to use destroy method instead. https://github.com/mootools/mootools-core/blob/master/Docs/Element/Element.md#element-method-dispose-elementdispose https://github.com/mootools/mootools-core/blob/master/Docs/Element/Element.md#element-method-empty-elementempty https://github.com/mootools/mootools-core/blob/master/Docs/Element/Element.md#element-method-destroy-elementdestroy Closes #19034. PR #19969.
This commit is contained in:
parent
19b88b7f4a
commit
9fde5634f1
7 changed files with 15 additions and 18 deletions
|
@ -817,8 +817,7 @@ window.qBittorrent.DynamicTable = (function() {
|
|||
let rowPos = rows.length;
|
||||
|
||||
while ((rowPos < trs.length) && (trs.length > 0)) {
|
||||
trs[trs.length - 1].dispose();
|
||||
trs.pop();
|
||||
trs.pop().destroy();
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -840,7 +839,7 @@ window.qBittorrent.DynamicTable = (function() {
|
|||
this.selectedRows.erase(rowId);
|
||||
const tr = this.getTrByRowId(rowId);
|
||||
if (tr !== null) {
|
||||
tr.dispose();
|
||||
tr.destroy();
|
||||
this.rows.erase(rowId);
|
||||
return true;
|
||||
}
|
||||
|
@ -852,8 +851,7 @@ window.qBittorrent.DynamicTable = (function() {
|
|||
this.rows.empty();
|
||||
const trs = this.tableBody.getElements('tr');
|
||||
while (trs.length > 0) {
|
||||
trs[trs.length - 1].dispose();
|
||||
trs.pop();
|
||||
trs.pop().destroy();
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -1562,7 +1560,7 @@ window.qBittorrent.DynamicTable = (function() {
|
|||
|
||||
if (!country_code) {
|
||||
if (td.getChildren('img').length > 0)
|
||||
td.getChildren('img')[0].dispose();
|
||||
td.getChildren('img')[0].destroy();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue