- Resource leak in SetupDiGetClassDevs()?
- Posted by p_monks on May 19th, 2008
Hope this is the right newsgroup to post to. I've found a problem with trying
to find out if a device is connected (under Windows XP if it makes any
difference). I'm using the SetupDiGetClassDevs() function to get all the
current device info, and afterwards I call SetupDiDestroyDeviceInfoList()
(like MSDN tells you to do) to clean up the memory.
The problem I've found is that the memory nevers seems to be freed. Looking
in Task Manager, I see the memory just keep going up, and using a tool to
find memory leaks tells me that this handle is never being cleaned up.
Has anyone else ever experienced this? If so, what should I do to fix this?
I really need to check for the presence of a device, it can't be avoided, but
I don't want to be constantly leaking memory.
- Posted by Farhan Ahmed [MSFT] on May 19th, 2008
What OS is this? Also, what is the return code from
SetupDiDestroyDeviceInfoList()? If FALSE, what does GetLastError() say?
- Farhan
-----Original Message-----
From: p_monks [mailto
_monks@discussions.microsoft.com]
Posted At: Monday, May 19, 2008 6:20 AM
Posted To: microsoft.public.development.device.drivers
Conversation: Resource leak in SetupDiGetClassDevs()?
Subject: Resource leak in SetupDiGetClassDevs()?
Hope this is the right newsgroup to post to. I've found a problem with
trying
to find out if a device is connected (under Windows XP if it makes any
difference). I'm using the SetupDiGetClassDevs() function to get all the
current device info, and afterwards I call SetupDiDestroyDeviceInfoList()
(like MSDN tells you to do) to clean up the memory.
The problem I've found is that the memory nevers seems to be freed.
Looking
in Task Manager, I see the memory just keep going up, and using a tool to
find memory leaks tells me that this handle is never being cleaned up.
Has anyone else ever experienced this? If so, what should I do to fix
this?
I really need to check for the presence of a device, it can't be avoided,
but
I don't want to be constantly leaking memory.
- Posted by p_monks on May 20th, 2008
Its Windows XP SP2. SetupDiDestroyDeviceInfoList() returns TRUE, so there are
no errors, and I can get all the device info I need OK. It just seems to be
leaking that handle created in SetupDiGetClassDevs().
"Farhan Ahmed [MSFT]" wrote: