Free Unmanaged Memory --- HELP!!!!!
I have a small memory leak and it is due to my inability to free some unmanaged memory why performing callbacks from a voice card. What happens is the program will run for a couple hours then crash. I get some errors that look to me like a memory leak. Please I thought API I am using would clean up the memory, but I thought wrong.
Here is my code
my DLLImport prototype
[DllImport("PikaAPI.dll")]
unsafe public static extern int PK_DSP_PORT_SetEventHandler(uint TResourceHandle, void* PK_VOID, EventHandlerCB EventHandler);
//My Callback delegate
unsafe public delegate void EventHandlerCB(void* vpUserData, uint uiEvent, uint uiParam0, uint uiParam1);
//Set event handler on the voice card
//Set Tone Detection EventHanderl
if((PK_DSP_PORT_SetEventHandler(hMemberToneDetectInput, (void*)hMemberToneDetectInput, EvetHandler2)) != PK_SUCCESS)
{
}
else
{
}
//Event handler for all callbacks......
unsafe public static void EventHandler (void* vpUserData, uint uiEvent, uint uiParam0, uint uiParam1)
{
lock(EvQ)
{
EvQ[iQIn].uiUserData = (uint)vpUserData;
EvQ[iQIn].uiEvent = uiEvent;
EvQ[iQIn].uiParam0 = uiParam0;
EvQ[iQIn].uiParam1 = uiParam1;
}
//Do Stuff here
//Reset Event Queue to control size
iQIn++
if(iQIn == 200)
iQIn = 0;
}