Bumps [github.com/KimMachineGun/automemlimit](https://github.com/KimMachineGun/automemlimit) from 0.4.0 to 0.5.0. - [Commits](https://github.com/KimMachineGun/automemlimit/compare/v0.4.0...v0.5.0) --- updated-dependencies: - dependency-name: github.com/KimMachineGun/automemlimit dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
30 lines
660 B
Go
30 lines
660 B
Go
// +build linux
|
|
|
|
package memory
|
|
|
|
import "syscall"
|
|
|
|
func sysTotalMemory() uint64 {
|
|
in := &syscall.Sysinfo_t{}
|
|
err := syscall.Sysinfo(in)
|
|
if err != nil {
|
|
return 0
|
|
}
|
|
// If this is a 32-bit system, then these fields are
|
|
// uint32 instead of uint64.
|
|
// So we always convert to uint64 to match signature.
|
|
return uint64(in.Totalram) * uint64(in.Unit)
|
|
}
|
|
|
|
func sysFreeMemory() uint64 {
|
|
in := &syscall.Sysinfo_t{}
|
|
err := syscall.Sysinfo(in)
|
|
if err != nil {
|
|
return 0
|
|
}
|
|
// If this is a 32-bit system, then these fields are
|
|
// uint32 instead of uint64.
|
|
// So we always convert to uint64 to match signature.
|
|
return uint64(in.Freeram) * uint64(in.Unit)
|
|
}
|