Skip to content

Commit a0bbcca

Browse files
author
Dylan Myers
committed
Only handle virtual memory when specifically requested
1 parent 3bf34ce commit a0bbcca

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

mem/mem_aix_nocgo.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
)
1313

1414
func VirtualMemoryWithContext(ctx context.Context) (*VirtualMemoryStat, error) {
15-
vmem, swap, err := callSVMon(ctx)
15+
vmem, swap, err := callSVMon(ctx, true)
1616
if err != nil {
1717
return nil, err
1818
}
@@ -25,7 +25,7 @@ func VirtualMemoryWithContext(ctx context.Context) (*VirtualMemoryStat, error) {
2525
}
2626

2727
func SwapMemoryWithContext(ctx context.Context) (*SwapMemoryStat, error) {
28-
_, swap, err := callSVMon(ctx)
28+
_, swap, err := callSVMon(ctx, false)
2929
if err != nil {
3030
return nil, err
3131
}
@@ -35,7 +35,7 @@ func SwapMemoryWithContext(ctx context.Context) (*SwapMemoryStat, error) {
3535
return swap, nil
3636
}
3737

38-
func callSVMon(ctx context.Context) (*VirtualMemoryStat, *SwapMemoryStat, error) {
38+
func callSVMon(ctx context.Context, virt bool) (*VirtualMemoryStat, *SwapMemoryStat, error) {
3939
out, err := invoke.CommandWithContext(ctx, "svmon", "-G")
4040
if err != nil {
4141
return nil, nil, err
@@ -45,7 +45,7 @@ func callSVMon(ctx context.Context) (*VirtualMemoryStat, *SwapMemoryStat, error)
4545
vmem := &VirtualMemoryStat{}
4646
swap := &SwapMemoryStat{}
4747
for _, line := range strings.Split(string(out), "\n") {
48-
if strings.HasPrefix(line, "memory") {
48+
if virt && strings.HasPrefix(line, "memory") {
4949
p := strings.Fields(line)
5050
if len(p) > 2 {
5151
if t, err := strconv.ParseUint(p[1], 10, 64); err == nil {

0 commit comments

Comments
 (0)