-
Notifications
You must be signed in to change notification settings - Fork 18k
os/exec: exec.command has memory leak #20980
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Are you using
http://tip.golang.org/pkg/os/exec/#Cmd.Start
Note the |
We are using Start() as well as Wait(), still we have memory leak. |
@Durgababu please provide a short program that reproduces the problem. Otherwise it's very hard to tell whether there is an issue with how you're using the exec package. |
str := "df -lPT -B1 -x iso9660" cmd := exec.Command(binary) errStart := cmd.Start() |
Are you sending SIGKILLs to the processes spawned for your
Also you're not checking the |
yes. We are sending SIGKILL to stop the command execution if it reaches timeout. |
We added error checking for cmd.Wait(), it is exiting without errors(nil). |
We did memory profile for above code using pprof package. It is showing leak in below lines of code: can someone help? |
IMHO you should ask for help in an appropriate place (see the Questions wiki page; it has a list of good places for asking for help on your code). If you ask for help in one of those places, please try to post an auto-contained example. The code you posted above is not auto-contained, because I can't just copy-past it in a text-file and run it. It has no main, the code includes a It's not even clear to me that the leak is real because you're not explaining how you're measuring memory usage. How do you know there's a leak? What |
I agree with @ALTree. The discussion could go on, but this question doesn't belong in the issue tracker. I'm going to close this for now. Feel free to open a new issue if you believe you found a bug. But please, as Alberto says, do provide a reproducible example - otherwise it's likely just a question. |
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?1.8.3
What operating system and processor architecture are you using (
go env
)?linux
What did you do?
we are using exec.Command() method many places. And we observed that there is memory leak in each call to this. Even after running running.GC(), it is not getting freeing up.
If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
We did memory profile using pprof package. It is showing leak in below code:
os/exec.Command(/usr/local/go/src/os/exec/exec.go:133)
os/exec.(*Cmd).start(usr/local/go/src/os/exec/exec.go:368)
os/exec.(*Cmd).start(usr/local/go/src/os/exec/exec.go:359)
The text was updated successfully, but these errors were encountered: