wmi icon indicating copy to clipboard operation
wmi copied to clipboard

Memory Leak

Open nook24 opened this issue 3 years ago • 6 comments

Hi, I'm facing memory leak issues when querying the Windows Event Log through this lib.

I'm new to Golang so properly I'm just doing something wrong. I found the issues #27 and #3 and maybe there is still a memory issue around.

I created a little code snip you can execute which shows the issue: https://github.com/nook24/wmi_windows_eventlog/blob/main/main.go

This Code is running on Windows Server 2016

Bildschirmfoto 2021-03-22 um 17 30 02

Even if the numbers are different from what Task Manager reports the memory usage is rising in Task Manager as well.

memleak

nook24 avatar Mar 22 '21 16:03 nook24

We are also having same issue and now we are testing it. Anybody else having the same problem?

yusufozturk avatar May 17 '21 10:05 yusufozturk

We are also having same issue and now we are testing it. Anybody else having the same problem?

In my case, it was due to wrong syscall usage. We use WMI heavily and it's good so far.

yusufozturk avatar Jul 13 '21 08:07 yusufozturk

In my case, it was due to wrong syscall usage. We use WMI heavily and it's good so far.

What do you mean by wrong syscall usage? We are using WMI a lot, and it looks like that the memory leak does only happen when querying the Windows Event Log. Do you also query the Windows Event Log and if yes, how does your implementation differ from my I posted above?

My current workaround for this is to use PowerShell and not WMI to get the Job done, but I din't like this: https://github.com/it-novum/openitcockpit-agent-go/blob/main/checks/eventlog_windows.go#L90-L117

nook24 avatar Jul 13 '21 08:07 nook24

I mean, we have a lot of syscalls in the app and one of them was causing our memory leak. In your case, I wouldn't know. But we also have a lot of wmi calls and we don't have any memory leak at the moment, so maybe this package is not the reason.

Fyi, we use syscalls to collect event logs. Using wmi would be slower and would use more resources. I would suggest you to drop wmi calls for events.

For perfmon, I would also suggest syscalls.

yusufozturk avatar Jul 14 '21 15:07 yusufozturk

I found this on another thread @nook24 https://github.com/influxdata/telegraf/issues/6807#issuecomment-590256733. Does this help?

jesus-velez avatar Jan 06 '22 22:01 jesus-velez

NOTE: This project is no longer being actively maintained.

We recommend you refer to this fork: https://github.com/yusufpapurcu/wmi

tlimoncelli avatar Jan 07 '22 16:01 tlimoncelli