Skip to content

Commit

Permalink
Modify calculating free memory method
Browse files Browse the repository at this point in the history
  • Loading branch information
NanXiao committed Apr 27, 2018
1 parent 36e44e5 commit cc73078
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# free
[free](https://linux.die.net/man/1/free) command for `OpenBSD`:

# ./free
total used free
Mem: 4032M 28M 4004M
Swap: 0B 0B 0B
P.S, I use [uvmexp.active](https://github.com/openbsd/src/blob/dbdab68da3b0b11846f6b023c8e069c40aa1fd71/sys/uvm/uvmexp.h#L50) to denote "`used`" memory, not "[uvmexp.npages](https://github.com/openbsd/src/blob/dbdab68da3b0b11846f6b023c8e069c40aa1fd71/sys/uvm/uvmexp.h#L48) - [uvmexp.free](https://github.com/openbsd/src/blob/dbdab68da3b0b11846f6b023c8e069c40aa1fd71/sys/uvm/uvmexp.h#L49)".
## Usage

# git clone https://github.com/NanXiao/free.git
# cd free
# make
# free
[free](https://linux.die.net/man/1/free) command for `OpenBSD`:

# ./free
total used free
Mem: 4032M 28M 4004M
Swap: 0B 0B 0B

## Usage

# git clone https://github.com/NanXiao/free.git
# cd free
# make
# ./free
4 changes: 2 additions & 2 deletions free.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ int main(int argc, char **argv)
err(1, "pledge");
}

used_mem = (int64_t)uvm.pagesize * uvm.active;
free_mem = phy_mem - used_mem;
free_mem = (int64_t)uvm.pagesize * uvm.free;
used_mem = phy_mem - free_mem;

swap = (int64_t)uvm.pagesize * uvm.swpages;
used_swap = (int64_t)uvm.pagesize * uvm.swpginuse;
Expand Down

0 comments on commit cc73078

Please sign in to comment.