ODBC SQLCloseCursor or SQLFreeHandle does not free the memory allocated to read CLOB
I am using a C++ application that connects to Oracle Database using EasySoft ODBC driver. I face a strange problem when freeing the dynamically allocated memory to fetch the CLOB data. SQLCloseCursor does not release the memory of the variable used to read the clob data.
The piece of Code is below,
char *pClobBuffer = new char; // 10 MB
// Prepare the SQL statement
strcpy(pQuery, "SELECT clobdata FROM clobtable")
/* Execute the SQL statement. Check for errors. */
SQLGetData(stmtHandle, 1, SQL_C_CHAR, pClobBuffer, 10485670,&dError);
The statement and connection handles are closed properly. Still i am seeing the memory usage is exactly increasing by 10 MB(size of the buffer we allocated to read the CLOB) for each query.
This is not happening when i allocate pClobBuffer as a static array.
I face this problem only when i allocate it dynamically. We tried running this with Purify, it's not a memory leak only the memory usage of the process is increasing. This 10 MB increase is happening when i issue the DB query everytime.
I tried changing the CLOB to Varchar in the database table, the above piece of Code works without increase in memory usage.
NOTE: We observed there is some special handling required to free the memory buffer allocated to read the CLOB field. In DB2 site they are saying SQLFreeStmt does not free the CLOB fields, FREE Alocator statement must be used.
Please suggest me if any special handling is required for ORACLE database also to free the CLOB data.
Our Env: C++, Solaris, ODBC 3.0, Oracle 9i, EasySoft driver