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
}
有疑问加站长微信联系(非本文作者)