MCPcopy Create free account
hub / github.com/modem-dev/hunk / readProcessMemory

Function readProcessMemory

scripts/daemon-memory-check.ts:209–225  ·  view source on GitHub ↗
(pid: number)

Source from the content-addressed store, hash-verified

207}
208
209async function readProcessMemory(pid: number) {
210 const linux = parseLinuxStatus(pid);
211 if (linux) {
212 return linux;
213 }
214
215 const result = Bun.spawnSync(["ps", "-o", "rss=", "-p", String(pid)], {
216 stdout: "pipe",
217 stderr: "pipe",
218 });
219 const rssKb = Number(result.stdout.toString().trim());
220 return {
221 rssBytes: Number.isFinite(rssKb) ? rssKb * 1024 : 0,
222 heapBytes: null,
223 highWaterRssBytes: null,
224 };
225}
226
227function formatBytes(bytes: number | null) {
228 if (bytes === null) {

Callers 1

sampleFunction · 0.85

Calls 1

parseLinuxStatusFunction · 0.85

Tested by

no test coverage detected