From 34507e469c751ea2755afdcf362dd5a7b25e7ad0 Mon Sep 17 00:00:00 2001 From: rakzoser <82242062+rakzoser@users.noreply.github.com> Date: Thu, 31 Oct 2024 23:17:37 +0200 Subject: [PATCH 1/7] Added ram check --- .idea/caches/deviceStreaming.xml | 329 +++++++++++++++++++++++++++++++ .idea/components.iml | 9 + .idea/misc.xml | 6 + .idea/modules.xml | 8 + .idea/vcs.xml | 6 + .idea/workspace.xml | 45 +++++ src/ZenTabUnloader.mjs | 20 +- 7 files changed, 422 insertions(+), 1 deletion(-) create mode 100644 .idea/caches/deviceStreaming.xml create mode 100644 .idea/components.iml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 .idea/workspace.xml diff --git a/.idea/caches/deviceStreaming.xml b/.idea/caches/deviceStreaming.xml new file mode 100644 index 0000000..5a2f866 --- /dev/null +++ b/.idea/caches/deviceStreaming.xml @@ -0,0 +1,329 @@ + + + + + + \ No newline at end of file diff --git a/.idea/components.iml b/.idea/components.iml new file mode 100644 index 0000000..d6ebd48 --- /dev/null +++ b/.idea/components.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..a6e1098 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..d9e9703 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..b59815b --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + 1730409076332 + + + + \ No newline at end of file diff --git a/src/ZenTabUnloader.mjs b/src/ZenTabUnloader.mjs index fc7d070..cbf2397 100644 --- a/src/ZenTabUnloader.mjs +++ b/src/ZenTabUnloader.mjs @@ -6,6 +6,9 @@ XPCOMUtils.defineLazyPreferenceGetter(lazy, 'zenTabUnloaderTimeout', 'zen.tab-unloader.timeout-minutes', 20); XPCOMUtils.defineLazyPreferenceGetter(lazy, 'zenTabUnloaderExcludedUrls', 'zen.tab-unloader.excluded-urls', ''); + + XPCOMUtils.defineLazyPreferenceGetter(lazy, 'zenTabUnloaderRamThreshold', 'zen.tab-unloader.ram-threshold', 70); + const ZEN_TAB_UNLOADER_DEFAULT_EXCLUDED_URLS = [ '^about:', @@ -75,7 +78,16 @@ this.interval = setInterval(this.intervalListener.bind(this), ZenTabsIntervalUnloader.INTERVAL); this.#excludedUrls = this.lazyExcludeUrls; } - + + async getRAMUsage() { // RAM usage ceck + try { + const memoryInfo = await Components.utils.getMemoryInfo(); + const totalPhysicalMemory = memoryInfo.total; + const usedMemory = memoryInfo.resident; + return (usedMemory / totalPhysicalMemory) * 100; + } + } + get lazyExcludeUrls() { return [ ...ZEN_TAB_UNLOADER_DEFAULT_EXCLUDED_URLS, @@ -113,6 +125,12 @@ if (!lazy.zenTabUnloaderEnabled) { return; } + // Check RAM usage before proceeding + const ramUsage = await this.getRAMUsage(); + if (ramUsage < lazy.zenTabUnloaderRamThreshold) { + return; // Don't unload tabs if RAM usage is below threshold + } + const currentTimestamp = Date.now(); const excludedUrls = this.excludedUrls; const tabs = gBrowser.tabs; From d73068b377c90d8bc1727def5d9665dbf33b6354 Mon Sep 17 00:00:00 2001 From: Max <82242062+Max-109@users.noreply.github.com> Date: Sat, 2 Nov 2024 14:16:30 +0200 Subject: [PATCH 2/7] Delete .idea/caches/deviceStreaming.xml --- .idea/caches/deviceStreaming.xml | 329 ------------------------------- 1 file changed, 329 deletions(-) delete mode 100644 .idea/caches/deviceStreaming.xml diff --git a/.idea/caches/deviceStreaming.xml b/.idea/caches/deviceStreaming.xml deleted file mode 100644 index 5a2f866..0000000 --- a/.idea/caches/deviceStreaming.xml +++ /dev/null @@ -1,329 +0,0 @@ - - - - - - \ No newline at end of file From 5c58b1de63e14403465837f635656b6b76d971f3 Mon Sep 17 00:00:00 2001 From: Max <82242062+Max-109@users.noreply.github.com> Date: Sat, 2 Nov 2024 14:16:43 +0200 Subject: [PATCH 3/7] Delete .idea/misc.xml --- .idea/misc.xml | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 .idea/misc.xml diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index a6e1098..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file From c25e6d37a24b1a4f4345a8505ab2a5498183da1e Mon Sep 17 00:00:00 2001 From: Max <82242062+Max-109@users.noreply.github.com> Date: Sat, 2 Nov 2024 14:16:51 +0200 Subject: [PATCH 4/7] Delete .idea/components.iml --- .idea/components.iml | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 .idea/components.iml diff --git a/.idea/components.iml b/.idea/components.iml deleted file mode 100644 index d6ebd48..0000000 --- a/.idea/components.iml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file From 05849467c2540b63f474dd2c6202f3afea164542 Mon Sep 17 00:00:00 2001 From: Max <82242062+Max-109@users.noreply.github.com> Date: Sat, 2 Nov 2024 14:17:08 +0200 Subject: [PATCH 5/7] Delete .idea/vcs.xml --- .idea/vcs.xml | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 .idea/vcs.xml diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1dd..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file From 8b430368c2f9eb0d3ffdd869a1c0fa6184f57ea4 Mon Sep 17 00:00:00 2001 From: Max <82242062+Max-109@users.noreply.github.com> Date: Sat, 2 Nov 2024 14:17:16 +0200 Subject: [PATCH 6/7] Delete .idea/workspace.xml --- .idea/workspace.xml | 45 --------------------------------------------- 1 file changed, 45 deletions(-) delete mode 100644 .idea/workspace.xml diff --git a/.idea/workspace.xml b/.idea/workspace.xml deleted file mode 100644 index b59815b..0000000 --- a/.idea/workspace.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - - - - - - - - - 1730409076332 - - - - \ No newline at end of file From c8201f1cd2d52c3d6d5c9571b5d8e8f1cb44f168 Mon Sep 17 00:00:00 2001 From: Max <82242062+Max-109@users.noreply.github.com> Date: Sat, 2 Nov 2024 14:17:32 +0200 Subject: [PATCH 7/7] Delete .idea/modules.xml --- .idea/modules.xml | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 .idea/modules.xml diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index d9e9703..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file