Home > Forum > Check devices connected memory issue

Check devices connected memory issue

Sep 12, 2019
Fábio Antunes wrote
hello, first time posting

I am having a problem, i have instantiate a VideoCapture to capture image and i need to detected when the camera is disconnected
I created a timer that checks all the seconds the devices connected
VideoCapture test = new VideoCapture();
...do stuff....

Even that i am using dispose this action each time ocupies memory and never frees it, making the computer ram consumed goes through the roof.

I already try put it in a background worker and inside the timer and making using(VideoCapture test ....)
Also i cannot use Video_CaptureDevices on the one i am using to capture because it doesnt update the list of devices, only when its created.

Nothing has worked so far is there anyway to detect if the device is connected or not? Or am i doing something wrong?
1 Answer
Sep 12, 2019
Roman Minyaylov agent wrote

Sample code:

using DirectShowLib;

var devices = DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice);
foreach (var device in devices)

DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice) returns currently available video capture devices.