Skip to content

Commit

Permalink
Add back cached memory code logic.
Browse files Browse the repository at this point in the history
  • Loading branch information
time-killer-games committed Jan 6, 2024
1 parent a0f7854 commit 64f03bf
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion openbsd/OpenBSDMachine.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,18 @@ static void OpenBSDMachine_scanMemoryInfo(OpenBSDMachine* this) {
}

super->totalMem = uvmexp.npages * this->pageSizeKB;
super->usedMem = (uvmexp.npages - uvmexp.free) * this->pageSizeKB;
super->usedMem = (uvmexp.npages - uvmexp.free - uvmexp.paging) * this->pageSizeKB;

// Taken from OpenBSD systat/iostat.c, top/machine.c and uvm_sysctl(9)
const int bcache_mib[] = { CTL_VFS, VFS_GENERIC, VFS_BCACHESTAT };
struct bcachestats bcstats;
size_t size_bcstats = sizeof(bcstats);

if (sysctl(bcache_mib, 3, &bcstats, &size_bcstats, NULL, 0) < 0) {
CRT_fatalError("cannot get vfs.bcachestat");
}

super->cachedMem = bcstats.numbufpages * this->pageSizeKB;

/*
* Copyright (c) 1994 Thorsten Lockert <[email protected]>
Expand Down

0 comments on commit 64f03bf

Please sign in to comment.