Open frogh1 opened 11 months ago
Describe the bug When I call process.Percent,memory increases slowly
To Reproduce
package main import ( "fmt" "os" "strconv" "time" "github.com/shirou/gopsutil/v3/process" ) func main() { if len(os.Args) < 1 { fmt.Println("exec pid") return } pid, err := strconv.Atoi(os.Args[1]) if err != nil { fmt.Println("pid should int") return } p, err := process.NewProcess(int32(pid)) if err != nil { fmt.Println(err) return } for { cpu, _ = p.Percent(1 * time.Second) fmt.Printf("cpu:%.2f\n", cpu) } }
Environment (please complete the following information):
ver
/etc/os-release
uname -a
sw_vers
freebsd-version -k -r -u
ProductName: macOS ProductVersion: 12.7 BuildVersion: 21G816
Additional context
GO111MODULE="on" GOARCH="amd64" GOBIN="" GOCACHE="/Users/mf/Library/Caches/go-build" GOENV="/Users/mf/Library/Application Support/go/env" GOEXE="" GOEXPERIMENT="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOINSECURE="" GOMODCACHE="/Users/mf/go/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="darwin" GOPATH="/Users/mf/go" GOPRIVATE="" GOPROXY="https://goproxy.cn" GOROOT="/usr/local/go" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64" GOVCS="" GOVERSION="go1.20.10" GCCGO="gccgo" GOAMD64="v1" AR="ar" CC="clang" CXX="clang++" CGO_ENABLED="1" GOMOD="/dev/null" GOWORK="" CGO_CFLAGS="-O2 -g" CGO_CPPFLAGS="" CGO_CXXFLAGS="-O2 -g" CGO_FFLAGS="-O2 -g" CGO_LDFLAGS="-O2 -g" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/bh/sk4mvy391bn6rndd7q83wxkm0000gp/T/go-build1363534723=/tmp/go-build -gno-record-gcc-switches -fno-common"
yes, facing the same issue
When I run your code for 10 minutes, it does not increase memory.
Could you get a memory profile? Thank you.
Describe the bug When I call process.Percent,memory increases slowly
To Reproduce
Environment (please complete the following information):
ver
]/etc/os-release
and the result ofuname -a
]sw_vers
anduname -a
freebsd-version -k -r -u
anduname -a
]uname -a
]sw_vers
Additional context