The AUTOFREE feature

The AUTOFREE feature only works withresult generating statements executed by using SQLExecDirect, as it opens the cursor which is then closed and released by the corresponding SQLCloseCursor or SQLFreeStmt.

The AUTOFREE feature does not work when the application has to prepare a statement once and then execute it several times (for example, using SQLPrepare to prepare and then executing it by calling SQLExecute several times). When you close the cursor with SQLCloseCursor after SQLExecute, it only closes the cursor but does not release the cursor memory on the database server side. But if you close the cursor by using SQLFreeStmt with SQL_CLOSE or SQL_DROP, it not only closes and releases the cursor, but it also unprepares the statement. In the latter case there is savings of a network roundtrip, but the application is unable to execute the statement again until it reprepares it.

When AUTOFREE is enabled, the application sees an improvement in the network performance when the application closes the cursor with SQLCloseCursor or SQLFreeStmt with SQL_DROP.