@matterbridge/utils 3.10.13-dev-20261005-49e0dbd → 3.10.13-dev-20261008-55d98fb
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/runtimeBun.d.ts +1 -0
- package/dist/runtimeBun.js +12 -0
- package/dist/tracker.js +4 -4
- package/package.json +1 -1
package/dist/runtimeBun.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export declare function sleep(ms: number): Promise<void>;
|
|
|
11
11
|
export declare function which(command: string): string | null;
|
|
12
12
|
export declare function gc(force?: boolean): void;
|
|
13
13
|
export declare function setGcLevel(level?: 0 | 1 | 2): 0 | 1 | 2 | undefined;
|
|
14
|
+
export declare function memoryFootprint(): number;
|
|
14
15
|
export interface BunRuntimeInfo {
|
|
15
16
|
isBun: boolean;
|
|
16
17
|
version?: string;
|
package/dist/runtimeBun.js
CHANGED
|
@@ -85,6 +85,18 @@ export function gc(force = true) {
|
|
|
85
85
|
export function setGcLevel(level) {
|
|
86
86
|
return HAS_BUN_GLOBAL ? Bun.unsafe.gcAggressionLevel(level) : undefined;
|
|
87
87
|
}
|
|
88
|
+
export function memoryFootprint() {
|
|
89
|
+
if (HAS_BUN_GLOBAL) {
|
|
90
|
+
try {
|
|
91
|
+
const footprint = Bun.unsafe?.memoryFootprint?.();
|
|
92
|
+
if (typeof footprint === 'number' && Number.isFinite(footprint) && footprint > 0)
|
|
93
|
+
return footprint;
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return process.memoryUsage().rss;
|
|
99
|
+
}
|
|
88
100
|
export function getBunRuntimeInfo() {
|
|
89
101
|
const bun = getBun();
|
|
90
102
|
return {
|
package/dist/tracker.js
CHANGED
|
@@ -3,7 +3,7 @@ import os from 'node:os';
|
|
|
3
3
|
import { AnsiLogger, BRIGHT, CYAN, db, RED, RESET, YELLOW } from 'node-ansi-logger';
|
|
4
4
|
import { formatBytes, formatPercent, formatTimeStamp } from './format.js';
|
|
5
5
|
import { logModuleLoaded } from './loader.js';
|
|
6
|
-
import { isBun, gc, setGcLevel } from './runtimeBun.js';
|
|
6
|
+
import { isBun, gc, memoryFootprint, setGcLevel } from './runtimeBun.js';
|
|
7
7
|
logModuleLoaded('Tracker');
|
|
8
8
|
export class Tracker extends EventEmitter {
|
|
9
9
|
name;
|
|
@@ -124,8 +124,8 @@ export class Tracker extends EventEmitter {
|
|
|
124
124
|
entry.totalMemory = os.totalmem();
|
|
125
125
|
entry.peakTotalMemory = Math.max(prevEntry.peakTotalMemory, entry.totalMemory);
|
|
126
126
|
const mem = process.memoryUsage();
|
|
127
|
-
entry.rss =
|
|
128
|
-
entry.peakRss = Math.max(prevEntry.peakRss,
|
|
127
|
+
entry.rss = memoryFootprint();
|
|
128
|
+
entry.peakRss = Math.max(prevEntry.peakRss, entry.rss);
|
|
129
129
|
entry.heapUsed = mem.heapUsed;
|
|
130
130
|
entry.peakHeapUsed = Math.max(prevEntry.peakHeapUsed, mem.heapUsed);
|
|
131
131
|
entry.heapTotal = mem.heapTotal;
|
|
@@ -182,7 +182,7 @@ export class Tracker extends EventEmitter {
|
|
|
182
182
|
else if (bun && typeof gc === 'function' && typeof setGcLevel === 'function') {
|
|
183
183
|
try {
|
|
184
184
|
setGcLevel(2);
|
|
185
|
-
gc(
|
|
185
|
+
gc(true);
|
|
186
186
|
if (this.debug)
|
|
187
187
|
this.log.debug(`${CYAN}${BRIGHT}Bun garbage collection triggered at ${new Date(Date.now()).toLocaleString()}.${RESET}${db}`);
|
|
188
188
|
this.emit('gc_done', type, execution);
|
package/package.json
CHANGED