Re: ESQLC prepare/execute/free causes memory leak on server
Posted in 1998
Nick Rumble wrote: > Is anyone aware of problems with ESQL/C (7.?) causing a memory leak in > Online (7.12 -> 7.23) by not freeing memory off following a calling to > $FREE. A typical scenario might be: > > $CHAR col2val[10]; > > for (i = 0; i < 1000; i++) > { > $PREPARE p1 FROM SELECT * from table where col1 > 'A' and col2 = ?; > $DECLARE c1 CURSOR WITH HOLD FOR p1; > $EXECUTE c1 USING $col2val; > $FETCH c1 INTO .....; > $CLOSE c1; > $FREE p1; -- Add here -- EXEC SQL FREE c1; > } You haven't freed any of the cursors (only the prepared statement), so memory is being eaten up. This is a big change from pre-5 ESQL/C where freeing both the statement and the cursor was a core-dumping error. Yours, Jonathan Leffler (jleffler@earthlink.net) #include <many-aliases.h>