Question
Why is there a high memory usage when adding and removing processes from the Process Manager?
Answer
Adding and removing the processes should not be leaking memory. However, when seeing an increase of memory usage, it is recommended to verify that the handles to the HexSight processes are all released properly.
When getting a reference to a COM object (HexSight tool), it is important to use the ReleaseComObject() function on it, or to make sure it is properly deleted (C++) or reassigned to NULL or Nothing (.NET). Otherwise, a handle is maintained for the object, and it will remain alive, even if deleted using the RemoveProcess(). This is usually where the leaking symptoms happen.
In the VBNET version of the LocatorDemo, you can see that the references to the tools are always set to Nothing before the end of the scope, and that the GC (GarbageCollector) is ordered to completely remove any copy from memory. This is another way to do the ReleaseComObject().
Dim lAcquisition As HSACQUISITIONDEVICELib.HSAcquisitionDevice
lAcquisition = applicationControl.ProcessManager.Process("Acquisition") applicationControl.ProcessManager.Execute("Acquisition") System.Runtime.InteropServices.Marshal.ReleaseComObject(lAcquisition) lAcquisition = Nothing
Comments
0 comments
Please sign in to leave a comment.