pprof占用内存代码如下:
![QQ截图20230523102526.png](https://static.golangjob.cn/230523/a4c4cfdca663005c470aac139880c49a.png)
代码
func FirewallRulesGet() ([]FWRule, error) {
rules := make([]FWRule, 1000)
u, fwPolicy, err := firewallAPIInit()
if err != nil {
return rules, err
}
defer firewallAPIRelease(u, fwPolicy)
ur, ep, enum, err := firewallRulesEnum(fwPolicy)
if err != nil {
return rules, err
}
defer firewallRulesEnumRealease(ur, ep)
for itemRaw, length, err := enum.Next(1); length > 0; itemRaw, length, err = enum.Next(1) {
if err != nil {
return rules, fmt.Errorf("failed to seek next Rule item: %s", err)
}
rule, err := firewallRuleParams(itemRaw)
if err != nil {
return rules, err
}
rules = append(rules, rule)
}
return rules, nil
}
使用代理还不能访问chatgpt的看过来 用这个: https://chaintz.top 或者这个: https://store.chaintz.app/ 或者这个:https://www.chainuk.top/
#3
更多评论
你先更新一下这个库的版本看看。你图里发的 `rules := make([]FWRule,1000)` 这里不对吧,下面用的是 `append`。新版本现在是 `rules := make([]FWRule, 0, 1024)`。你现在这个版本应该有问题,这个 issue 修复了 [Memory leak while using firewall.go](https://github.com/iamacarpet/go-win64api/issues/39)。
#1