SBC2: Bug in Phidget22 C library (20190107) memory leak for VoltageRatioInput.
Posted: Wed Jan 09, 2019 8:14 am
Using Phidget22 version 2.1.9.20190107-1
When compiling on the SBC2 I'm seeing a memory leak when calling the Phidget_openWaitForAttachment with Phidget_close on a PhidgetVoltageRatioInput channel but not on DigitalInput channel.
Using cut down sample code (including the the common code from the samples)
The opening and closing of a VoltageRatioInput channel produces a memory leak for me.
Similar code for a DigitalInput channel does not produce a memory leak.
When compiling on the SBC2 I'm seeing a memory leak when calling the Phidget_openWaitForAttachment with Phidget_close on a PhidgetVoltageRatioInput channel but not on DigitalInput channel.
Using cut down sample code (including the the common code from the samples)
The opening and closing of a VoltageRatioInput channel produces a memory leak for me.
Code: Select all
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <phidget22.h>
#include "PhidgetHelperFunctions.h"
int main() {
PhidgetVoltageRatioInputHandle ch = NULL;
PhidgetReturnCode prc;
while(1)
{
prc = PhidgetVoltageRatioInput_create(&ch);
CheckError(prc, "Creating Channel", (PhidgetHandle *)&ch);
prc = Phidget_setDeviceSerialNumber((PhidgetHandle)ch, -1);
CheckError(prc, "Setting DeviceSerialNumber", (PhidgetHandle *)&ch);
prc = Phidget_setHubPort((PhidgetHandle)ch, -1);
CheckError(prc, "Setting HubPort", (PhidgetHandle *)&ch);
prc = Phidget_setIsHubPortDevice((PhidgetHandle)ch, 0);
CheckError(prc, "Setting IsHubPortDevice", (PhidgetHandle *)&ch);
prc = Phidget_setChannel((PhidgetHandle)ch, 0);
CheckError(prc, "Setting Channel", (PhidgetHandle *)&ch);
prc = Phidget_openWaitForAttachment((PhidgetHandle)ch, 5000);
CheckOpenError(prc, (PhidgetHandle *)&ch);
Sleep(100);
prc = Phidget_close((PhidgetHandle)ch);
CheckError(prc, "Closing Channel", (PhidgetHandle *)&ch);
prc = PhidgetVoltageRatioInput_delete(&ch);
CheckError(prc, "Deleting Channel", (PhidgetHandle *)&ch);
}
return 0;
}
Similar code for a DigitalInput channel does not produce a memory leak.
Code: Select all
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <phidget22.h>
#include "PhidgetHelperFunctions.h"
int main() {
PhidgetDigitalInputHandle ch = NULL;
PhidgetReturnCode prc;
while(1){
prc = PhidgetDigitalInput_create(&ch);
CheckError(prc, "Creating Channel", (PhidgetHandle *)&ch);
prc = Phidget_setDeviceSerialNumber((PhidgetHandle)ch, -1);
CheckError(prc, "Setting DeviceSerialNumber", (PhidgetHandle *)&ch);
prc = Phidget_setHubPort((PhidgetHandle)ch, -1);
CheckError(prc, "Setting HubPort", (PhidgetHandle *)&ch);
prc = Phidget_setIsHubPortDevice((PhidgetHandle)ch, 0);
CheckError(prc, "Setting IsHubPortDevice", (PhidgetHandle *)&ch);
prc = Phidget_setChannel((PhidgetHandle)ch, 2);
CheckError(prc, "Setting Channel", (PhidgetHandle *)&ch);
prc = Phidget_openWaitForAttachment((PhidgetHandle)ch, 5000);
CheckOpenError(prc, (PhidgetHandle *)&ch);
Sleep(100);
prc = Phidget_close((PhidgetHandle)ch);
CheckError(prc, "Closing Channel", (PhidgetHandle *)&ch);
prc = PhidgetDigitalInput_delete(&ch);
CheckError(prc, "Deleting Channel", (PhidgetHandle *)&ch);
}
return 0;
}