fix(pidusage): prune history entries for PIDs not present in the requested set to avoid stale data and memory growth
This commit is contained in:
@@ -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.'
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user