diff --git a/changelog.md b/changelog.md index 7719d2f..cfffa4d 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,12 @@ # Changelog +## 2026-03-02 - 3.0.2 - fix(pidusage) +prune history entries for PIDs not present in the requested set to avoid stale data and memory growth + +- Deletes entries from the history map when a PID is not included in the current pids array +- Prevents accumulation of stale PID histories and potential memory growth +- Change implemented in ts/smartmetrics.pidusage.ts alongside the metrics result construction + ## 2026-02-19 - 3.0.1 - fix(smartmetrics) no code changes detected; no version bump or release required diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index 9dca734..c627098 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@push.rocks/smartmetrics', - version: '3.0.1', + version: '3.0.2', description: 'A package for easy collection and reporting of system and process metrics.' } diff --git a/ts/smartmetrics.pidusage.ts b/ts/smartmetrics.pidusage.ts index a975a87..eba289a 100644 --- a/ts/smartmetrics.pidusage.ts +++ b/ts/smartmetrics.pidusage.ts @@ -125,5 +125,12 @@ export async function getPidUsage( }); } + // Prune history entries for PIDs no longer in the requested set + for (const histPid of history.keys()) { + if (!pids.includes(histPid)) { + history.delete(histPid); + } + } + return result; }