Memory usage remains below 50MB during sustained operation
Why it matters
Memory leaks in background scripts and content scripts accumulate silently across browsing sessions and tabs. A module-scope Map that grows on every webRequest without eviction, or event listeners added in repeated callbacks without removal, will grow until Chrome kills the extension process or the user notices slowdown. CWE-770 (Allocation of Resources Without Limits or Throttling) and ISO 25010:2011 performance-efficiency.resource-utilisation both cover this pattern. Extensions that trigger Chrome's "High memory usage" warning in the Task Manager get uninstalled.
Severity rationale
High because unbounded memory growth from caches or listener accumulation eventually degrades system performance and triggers process termination, losing all in-memory state.
Remediation
Add explicit size limits and eviction to every cache, and use named listener functions that can be removed when their context is no longer valid.
// Bounded cache with FIFO eviction
const MAX_CACHE_SIZE = 500;
const resultsCache = new Map();
function cacheResult(key, value) {
if (resultsCache.size >= MAX_CACHE_SIZE) {
resultsCache.delete(resultsCache.keys().next().value);
}
resultsCache.set(key, value);
}
// Removable listener — never add anonymous functions inside callbacks
function onTabUpdate(tabId, changeInfo, tab) { /* ... */ }
chrome.tabs.onUpdated.addListener(onTabUpdate);
// When done: chrome.tabs.onUpdated.removeListener(onTabUpdate);
Audit all module-scope Map, Set, and array declarations for unbounded growth paths.
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the Extension UX & Performance Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- cwe · CWE-770 — Allocation of Resources Without Limits or Throttling
- iso-25010:2011 · performance-efficiency.resource-utilization
Taxons
History
- 2026-04-18·v1.0.0·Initial import from extension-ux-performance·automated