I'm trying to use Golang's win64api library(https://github.com/kumako/go-win64api) to control windows firewall.
It works well, but it doesn't release memory. For example, running functions in a loop will cause continuous incremental memory usage.
Looking at the library, it seems that this topic is taken care of(functions like firewallAPIRelease, firewallRulesEnumRealease).
Does anyone have an idea why this is happening?
Here's a code that causes the problem:
package main
import (
"fmt"
winapi "github.com/kumako/go-win64api"
"time"
)
func main(){
var first string
for 1>0 {
fmt.Scanln(&first)
if first == "run"{
firewallTest()
}
}
}
func firewallTest(){
//get the list of the rules
ruleList, _ := winapi.FirewallRulesGet()
//delete them one by one using their names
for _, eachRule := range ruleList {
ruleName := eachRule.Name
if ruleName != ""{
winapi.FirewallRuleDelete(ruleName)
}
}
//wait for 30 second
time.Sleep(30 * time.Second)
//add them back, one by one, from the list
for _, eachRule := range ruleList{
winapi.FirewallRuleAddAdvanced(eachRule)
}
}