B
beattie.stuart
I think I've found a memory leak trying to use the
system.management.ManagementObject, but it could be my programming
skills so I'd appreciate some advice. I've writing a monitoring routine
that queries WMI for some stats, but it continually eats into memory.
I've cut the code down to the following sample but the problem is still
there:
Imports System
Imports System.Management
Module Module1
Private mObjectCpu As ManagementObject
Sub Main()
Dim Counter As Int32
While Counter < 10000
mObjectCpu = New
ManagementObject("Win32_PerfRawData_PerfOS_Processor.Name='_Total'")
mObjectCpu.Get()
mObjectCpu.Dispose()
Counter += 1
End While
End Sub
End Module
I've used the .Net Memory Profiler from Scitech and it's showing a load
of undisposed instances of the object
System.Management.IWbemClassObjectFreeThreaded, but I don't have
references to it in my code, and I can't find anything about it in
MSDN.
Does anyone have any ideas what I've done wrong, or has anyone seen
this kind of problem before?
Cheers,
Stu
system.management.ManagementObject, but it could be my programming
skills so I'd appreciate some advice. I've writing a monitoring routine
that queries WMI for some stats, but it continually eats into memory.
I've cut the code down to the following sample but the problem is still
there:
Imports System
Imports System.Management
Module Module1
Private mObjectCpu As ManagementObject
Sub Main()
Dim Counter As Int32
While Counter < 10000
mObjectCpu = New
ManagementObject("Win32_PerfRawData_PerfOS_Processor.Name='_Total'")
mObjectCpu.Get()
mObjectCpu.Dispose()
Counter += 1
End While
End Sub
End Module
I've used the .Net Memory Profiler from Scitech and it's showing a load
of undisposed instances of the object
System.Management.IWbemClassObjectFreeThreaded, but I don't have
references to it in my code, and I can't find anything about it in
MSDN.
Does anyone have any ideas what I've done wrong, or has anyone seen
this kind of problem before?
Cheers,
Stu