KnicKnic / KnicKnic/go-powershell
Memory leak
- Dominant language
- Go
- Stars
- 126
- Forks
- 7
- PR merge metrics
- No merged PRs in 30d
Description
Memory will increase dramatically by just execute a script and read response.
The example below will consume your memory 2MB/s, and not go down any more
```go
func do() {
rs := powershell.CreateRunspaceSimple()
defer rs.Close()
script := `
Get-NetRoute | ConvertTo-Json
`
res := rs.ExecScript(script, false, nil)
defer res.Close()
log.Println(res.Exception.ToString())
if len(res.Objects) > 0 {
log.Println(len(res.Objects[0].ToString()))
}
}
func main() {
for {
do()
}
}
```
My application will sleep 5 minutes between every `do()`, and still increasing. It seams some memory not freed by GOGC
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the loop using powershell.CreateRunspaceSimple, ExecScript, and the deferred Close calls shown in the issue, while measuring memory over repeated executions. Trace the runspace and response lifecycle to identify what remains allocated after do() returns. Done means the example no longer shows unbounded growth, including with the five-minute interval described.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, powershell
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100