Skip to content

Commit 178d6e0

Browse files
committed
采集网络接口的时候,会出现内存泄漏
1 parent 6911d16 commit 178d6e0

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

metric/system/net.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,9 @@ func (s *NetIOStats) Collect() (datas []map[string]interface{}, err error) {
217217

218218
func (s *NetIOStats) initInterfaces() {
219219
if interfaces, err := net.Interfaces(); err == nil {
220+
if len(s.InterfacesMap) > 0 {
221+
s.InterfacesMap = make(map[string]net.Interface)
222+
}
220223
for _, _interface := range interfaces {
221224
s.InterfacesMap[_interface.Name] = _interface
222225
}

0 commit comments

Comments
 (0)