Skip to content

Commit

Permalink
add nocopy
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexStocks committed Dec 9, 2020
1 parent c67f523 commit 928960b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion runtime/sys.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func GetCPUNum() int {
return runtime.NumCPU()
}

// GetMemoryLimit gets current os's memory size in bytes
// GetMemoryStat gets current os's memory size in bytes
func GetMemoryStat() (total, used, free uint64, usedPercent float64) {
stat, err := mem.VirtualMemory()
if err != nil {
Expand All @@ -59,6 +59,7 @@ func GetMemoryStat() (total, used, free uint64, usedPercent float64) {
return stat.Total, stat.Used, stat.Free, stat.UsedPercent
}

// IsCgroup checks whether current os is a container or not
func IsCgroup() bool {
ok, _ := gxfilepath.Exists(cgroupMemLimitPath)
if ok {
Expand All @@ -68,6 +69,7 @@ func IsCgroup() bool {
return false
}

// GetCgroupMemoryLimit returns a container's total memory in bytes
func GetCgroupMemoryLimit() (uint64, error) {
return readUint(cgroupMemLimitPath)
}
Expand Down
2 changes: 1 addition & 1 deletion runtime/sys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestSysStat(t *testing.T) {

size := 100 * 1024 * 1024
arr := make([]byte, size)
for idx, _ := range arr {
for idx := range arr {
arr[idx] = byte(idx / 255)
}
memoryStat, err := GetProcessMemoryStat()
Expand Down

0 comments on commit 928960b

Please sign in to comment.