I've hit a brick wall. In calling a "C" dll, not C++ or Com, one
of the functions returns a pointer to a type. The data is returned
without a problem but a subsequent call to a function is required
to free the pointer/data. This is where my problem occurs. The memory
is not being released although the data in the type is being zeroed out.
This function is call roughly 3000 times a minute and watching the
memory grow in the task manager is daunting. I have compiled the
"C" sample code and it does indeed release the memory properly. Any
ideas would be appreciated. Below is my translations and a snippet
of code showing how the functions are being called.
I have tried it on ME, WinNT 4.0 and Win2000 to insure that it is
not a platform issue.
Code:
'typedef struct '{ ' int iType; ' const char* szItem; ' LPVOID lpData; ' DWORD dwDataLen; ' const char* szDataFormat; '} TALConvData; TYPE TALConvDataType iType AS LONG szItem AS ASCIIZ PTR lpData AS LONG PTR dwDataLen AS DWORD szDataFormat AS ASCIIZ PTR END TYPE 'int FAR PASCAL TALConvWaitForData( DWORD dwConv , DWORD dwTimeout ); 'TALConvData* FAR PASCAL TALConvGetData( DWORD dwConv ); 'void FAR PASCAL (TALConvFreeData( TALConvData* pData ); DECLARE FUNCTION TALConvWaitForData LIB "talapi32.dll" ALIAS "TALConvWaitForData"( BYVAL dwConv AS DWORD, BYVAL dwTimeout AS DWORD ) AS LONG DECLARE FUNCTION TALConvGetData LIB "talapi32.dll" ALIAS "TALConvGetData"( BYVAL dwConv AS DWORD ) AS LONG DECLARE SUB TALConvFreeData LIB "talapi32.dll" ALIAS "TALConvFreeData"( BYVAL pData AS DWORD ) LOCAL dwConv AS DWORD LOCAL pszText AS ASCIIZ PTR LOCAL pData AS TALConvDataType PTR DO SLEEP 10 DO lReturn = TALConvWaitForData( dwConv, 250 ) pData = TALConvGetData( dwConv ) SLEEP 5 LOOP WHILE( pData = %NULL ) pszText = @pData.lpData ' display the data. Because we requested ' DATA IN the format "TEXT" we can just use printf TO display it. SELECT CASE @pData.iType CASE %TALCONV_ADVISE_DATA 'Parsed and displayed correctly CALL ProcessIncomingData(@pszText) CASE %TALCONV_TERMINATE CALL AddToListBox ("TALConvAdvise received a Terminate from the server.." ) EXIT DO CASE ELSE CALL AddToListBox ("TALConvAdvise resulted in an unexpected message of type:" & STR$(@pData.iType )) EXIT DO END SELECT 'This line apparently does not properly 'release the memory although the data is 'zeroed out. CALL TALConvFreeData(pData) LOOP
------------------
Jim..
[email protected]
Comment