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;
}