Re: Freeing memory used by sqlda in ESQL/C
Posted in 1994
Jonathan Leffler writes: >Which version is which, you say? There I get stuck -- my memory is failing >or something. I think, but haven't time to verify, that 4.1x and 5.01 >(and, probably, 5.02) all free memory on re-describe, but 5.00 didn't free >and gave memory leaks unless you did it manually. This set of versions >would correspond to the changes I've had to make to my code. However, once >I got the change back, I started using a #define to indicate whether the >described SQLDA structure should be released or not. And I haven't yet >ensured that I have all the backwards compatability information in place. Some additional kindling for this fire: If you redeclare a cursor in 5.0 esql/c, you should also free it when you are done, else you will see your memory usage increase for each redeclare of the same cursor. So for some sample code: int f() { EXEC SQL declare c1 cursor for select * from foo; EXEC SQL open c1; for (;;) { EXEC SQL FETCH c1 INTO ...; if (sqlca.sqlcode == SQLNOTFOUND) break; } EXEC SQL close c1; EXEC SQL free c1; return(0); } Dave -- Disclaimer: These opinions are not those of Informix Software, Inc. ************************************************************************** "I look back with some satisfaction on what an idiot I was when I was 25, but when I do that, I'm assuming I'm no longer an idiot." - Andy Rooney