yako
New Member
Posts: 4
|
Post by yako on Jul 12, 2017 23:58:24 GMT
Alternatively, what is the proper way of updating to find out the new number of Blync Devices connected.
As it stands, the only way to find out how many BlyncLights are there is via the return value of InitBlyncDevices(). However, every call to this leaks some amount of memory. Close appear to only remove the native handle and does not release the memory in full.
There are no events to informs us that new devices are connected/disconnect like Embrava Connect's File -> Devices.
Any help would be appreciated. Thanks.
|
|
|
Post by Smith on Jul 15, 2017 5:51:14 GMT
Hi Yako, It seems that as per the SDK reference manual, when InitBlyncDevices is called, on exiting the application or before calling the InitBlyncDevices, CloseDevices must be called. Also once the InitBlyncDevices is called, it looks like that the device handle is opened and kept using native call CreateFile. CreateFile uses memory resources for the device object and the same will be freed once the device handle is closed. So when we want to know how many Blynclight devices are connected to the system, then we have to use the InitBlyncDevices. So if we don’t want the devices to be opened, then we can close the device handles using CloseDevices function. Then regarding the USB hotplugging notification of Blynclight devices, the Blynclight.dll driver library is just a C# class library, it seems its not sending the notification for USB hotplugging. But this is not possible. Instead we have to write our own USB hotplugging notification handlers - for plugging and removal in our own application code, using native functions such as RegisterDeviceNotification and UnregisterDeviceNotification. On plugging notification, we can call the InitBlyncDevices to get to know the number of Blynclight devices attached to the System. Example of such implementation can be found in the following link: www.codeproject.com/Articles/14500/Detecting-Hardware-Insertion-and-or-RemovalHope this helps. Thanks.
|
|
yako
New Member
Posts: 4
|
Post by yako on Jul 24, 2017 19:41:59 GMT
Hi, Thanks for your response and sorry for the very late reply. I figure we will have to go down the path USB Notification handling. That is not an issue.
However, it doesn't take away the fact that it is leaking memory. Let me show an example of this at its most extreme case.
var blc = new BlynclightController(); for ( var i = 0; i < 10000; ++i ) { var numDevices = blc.InitBlyncDevices(); blc.CloseDevices(numDevices); }
Watch as the memory ramp up. Now I believe this simplistic example is everything in accordance to the documentation and as per your comments with regards to initialising and closing down.
|
|
|
Post by Smith on Aug 7, 2017 4:30:36 GMT
Hi Yako,
Yes – I tried this and have noticed the same. Hopefully the admins will act on this.
Thanks, Smith
|
|
yako
New Member
Posts: 4
|
Post by yako on Aug 7, 2017 19:22:13 GMT
Thanks for your confirmation and support on the reported issue Smith. I too hope the Embrava devs pick up on this.
|
|
|
Post by Admin on Aug 19, 2017 4:28:11 GMT
Hi Guys,
Thanks for identifying and confirming this.
The team has added a fix for this in the next release of the SDK due to release 8th October.
We will let you know once released.
Thanks again!
|
|
|
Post by Admin on Sept 15, 2017 2:40:23 GMT
|
|
yako
New Member
Posts: 4
|
Post by yako on Oct 30, 2017 23:35:04 GMT
That was a lot earlier than expected, which is why I didn't check back until now. Thanks a lot!
|
|