Commit Graph

95 Commits

Author SHA1 Message Date
GameXG 144c67833a
fix #863 Swap.UsedPercent is inconsistent 2020-05-03 23:27:10 +08:00
Xuewei Zhang 929068ccd5 mem: Add VirtualMemoryEx() and VirtualMemoryExWithContext() 2020-01-30 18:46:47 -08:00
Xuewei Zhang 3695635d09 Collect Active(anon), Inactive(anon) and Unevictable in /proc/meminfo
These fields helps people understand anonymous memory usage pattern.
2020-01-30 17:47:09 -08:00
lanixzcj 38b78c3eac rename InActive(file) to Inactive(file) in mem_linux.go 2019-12-20 08:39:36 +08:00
Minje Park b7f9acbce8 add unreclaim metric, this closes #719 2019-07-20 23:42:39 +09:00
Segflow 86c7289ccc Fix: use filename in exec.LookPath instead of full path
exec.LookPath searches for the file in the $PATH, which mean giving it an absolute path is against it's own purposes.
2019-05-05 20:45:07 +01:00
lootek 1cbb212a6b
Add pages in/out/fault statistics (as read from vmstat) 2019-04-25 09:32:59 +02:00
mingrammer 64a995aad4 Refactor with gofmt 2019-03-23 21:57:24 +09:00
mingrammer 017c9f9cbc Fix typos 2019-03-18 02:52:26 +09:00
WAKAYAMA shirou bb15c85289 [mem][freebsd]: add SysctlUint which can adapt both 32 and 64 bit 2019-03-16 21:43:15 +09:00
Lomanic e3c878cc43 [mem][darwin] Remove calls to sysctl binary in mem/mem_darwin.go #639 2019-03-02 23:22:53 +01:00
shirou 6c6abd6d16
Merge pull request #626 from mznet/manual-available-memory-calculation
Manual available memory calculation
2019-03-01 22:30:41 +09:00
Minje Park c75deb9dc0 debug codes were removed 2019-02-13 01:02:18 +09:00
Minje Park 47ed6aaebd activefile and inactivefile fields were removed from VirtualMemoryStat 2019-02-13 00:55:05 +09:00
shirou b3d992b0f6 [mem]freebsd: update xswdev_version to adapt FreeBSD 12. 2019-02-10 23:19:06 +09:00
Minje Park d23abede78 struct typo and broken test case were fixed 2019-01-31 00:31:43 +09:00
Minje Park d7ce61cac8 Error checks and fallback for old linux 2019-01-31 00:13:52 +09:00
Minje Park 9fb3b9625d mem available fallback under kernel 2.6.13 2019-01-30 21:58:44 +09:00
Minje Park 73545ec820 AvailableMemory is't calculated automatically under kenel 3.14 so it is needed to calcuate manually
manual available memory calculation should be done if only memavail is false

Manual Available Memory calculation under kernel 3.14

accurate manaul available memory calculation
2019-01-06 23:21:59 +09:00
Lomanic ccc1c1016b [mem][darwin] Fix #622 include Inactive memory in total calculation in TestVirtual_memory 2018-12-25 21:55:58 +01:00
Minje Park f9e238c38b SReclaimable should be added to Cached Memory 2018-12-14 00:48:38 +09:00
Isida Zyun'iti bd7b2f8148 Add mem(laundry) numbers on FreeBSD.
After FreeBSD 11.1, mem number of cached replaced by laundry.

https://reviews.freebsd.org/D8302
2018-08-08 19:54:18 +09:00
Isida Zyun'iti 48da6ade9e Fix FreeBSD total memory.
Like this.
FreeBSD: fix total memory giampaolo/psutil@bd9a58b bd9a58b2af
2018-08-07 10:42:15 +00:00
Lomanic 6b586d2fcd [mem][windows] Fix TestVirtual_memory test 2018-07-19 00:19:02 +02:00
shirou 6b48f3bd01 [mem] fix test. 2018-07-13 23:34:38 +09:00
Arnaud Rebillout 558a95bf02 Fix TestVirtual_memory #552
Based on https://stackoverflow.com/a/30772733/776208

Signed-off-by: Arnaud Rebillout <arnaud.rebillout@collabora.com>
2018-07-12 13:05:28 +07:00
shirou 9937d4109d mem[linux]: fix test. 2018-06-23 23:38:51 +09:00
Shrug 42 6a38ce2069 fix json tags 2018-06-20 10:20:54 -07:00
Shrug 42 12fad953c1 added additional linux meminfo fields 2018-06-19 13:12:33 -07:00
Steven Lee 3adcafe5fd mem[windows]: if no swap, just return 0 used percent default 2018-05-19 10:45:38 +08:00
shirou 0f1576d63c mem[windows]: if no swap, total and/or used is 0. 2018-05-19 09:25:20 +09:00
Daniel Nelson 28b1d7477e
Use uint64 when retrieving vfs.bufspace
On some system using a the uint32 function would return the error
"cannot allocate memory".
2018-04-12 15:33:51 -07:00
shirou 145dca90f7 change to use CommandContext. 2018-03-31 21:35:53 +09:00
shirou c3f470a77a
Merge pull request #504 from dimrozakis/linux-used-mem
Always calculate linux used mem as total-(free+buffered+cache)
2018-03-28 11:00:28 +09:00
shirou 1ba5059aca [memory] Linux: add document url about OverCommiting. 2018-03-28 10:57:05 +09:00
shirou a1564d2e89
Merge pull request #478 from DataDog/olivielpeau/commit-vm-stats
[mem] Add commit-related stats to VirtualMemoryStat on Linux
2018-03-28 10:49:09 +09:00
Dimitris Rozakis 4510db20db Always calculate linux used mem as total-(free+buffered+cache)
Used memory was calculated as Total - Available.
For newer kernels (3.14+), available memory is taken from /proc/meminfo,
whereas for older kernels it is computed as free+buffered+cached.

This commit changes that behavior. Available memory is still taken from
/proc/meminfo, if available, but used memory is always computed as
total-free-buffered-cached.

This way, it matches the output of `free` for used memory (in the -/+
buffers/cache line) and other tools.

Prior to this change, I'd see a reported used memory of 600MiB whereas
free, htop and other tools would report a used memory of 1.8GiB. And
adding used, cached, buffered and free memory would leave ~1.2GiB
unaccounted for.
2018-03-26 21:38:02 +03:00
Chevy 699deed6c6
Fix float64 casting 2018-03-26 12:16:33 -05:00
Laurie Clark-Michalek 413cb32b6c Use static initialisation for invoke instances, instead of init funcs
The order of init function execution is dependant on the order that the
source files are passed to the compiler. This causes issues when
building under other build systems, such as bazel or buck, as they are
not guarenteed to maintain the same file order as the default go tool.
2018-03-21 14:08:39 +00:00
Steven Hartland d968f63e51 Eliminate call to swapinfo on FreeBSD
Improve performance by eliminating the fork out to swapinfo on FreeBSD which also helps prevent crashes / hangs due to the outstanding fork crash bug:
golang/go#15658

This also fixes the value reported by SwapMemory and SwapMemoryWithContext on FreeBSD which previously only included the first swap device and also reported the values in terms of 1K blocks instead of bytes.
2018-03-11 22:15:22 +00:00
shirou 4c73494c78 Add WithContext functions. 2017-12-31 15:25:49 +09:00
Olivier Vielpeau 5b52fbbea5 [mem] Add commit-related stats to VirtualMemoryStat on Linux 2017-12-26 16:24:10 +01:00
Steven Hartland 6450c60b61 Eliminate use of sysctl command on FreeBSD
In order to improve performance and help prevent crashes due to the outstanding fork crash bug:
https://github.com/golang/go/issues/15658

Replace string parsed values from the sysctl command with native reads of sysctl values using unix.SysctlRaw and unix.SysctlUint32.

This also merges OpenBSD and FreeBSD load implementations which are identical.
2017-10-05 08:45:56 +01:00
Derek Brown 7c807c86e4 Add implementation of SwapMemory() for windows 2017-09-18 18:14:29 -07:00
Sean Chittenden 635b971c0e
Move from the `syscall` package to the `golang.org/x/sys/{unix,windows}` 2017-06-02 13:51:00 -07:00
WAKAYAMA Shirou f8ef680a47 error strings change to lowercase 2017-03-15 22:43:20 +09:00
James Nugent d19ac24a84 mem: Skip TestVirtual_memory on Solaris 2017-03-15 08:10:23 -05:00
James Nugent b7760bb5a6 memory: Add basic Solaris VirtualMemory() support
This commit adds support for VirtualMemory() in package mem. The support
only extends to total memory capcity, since that is all that is required
in Nomad. It does take into account global versus non-global zones, and
does not use cgo.

This has been tested inside a zone in the Joyent public cloud for a
non-global zone, and in the global zone of a SmartOS virtual machine.
2017-03-14 16:28:50 -05:00
Cameron Sparr a213bf5e6d
run go fmt ./... 2017-02-01 23:05:29 +00:00
WAKAYAMA Shirou 1123132e5a [mem]darwin: swap memory was Kbytes, since linux is bytes. 2017-01-17 22:38:46 +09:00