Re: ESQLC prepare/execute/free causes memory leak on server
Posted in 1998
In article <893752477.1758.0.nnrp-04.c2d9cf02@news.demon.co.uk>, Nick Rumble <rumbln@tetraworld.com> writes > >Steve Breuer wrote in message <6i3f9s$kak@bgtnsc03.worldnet.att.net>... >>Nick Rumble <rumbln@tetraworld.com> wrote in article >><893682006.2920.0.nnrp-04.c2d9cf02@news.demon.co.uk>... >>> 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; >>> >>> } >> >>You missed freeing the cursor after you closed it. >> >> $FREE c1; >> >>Steve > >I thought that freeing the prepared statement used to declare the cursor, >implicitely freed the cursor ? > Nope, one frees resource in the 4GL process, one frees resources in the engine. PS I normally free the cursor before the prepared statement. Kinda like open a; open b; close b; close a. Keeps things symmetric and makes sure you don't forget things.. > -- David Williams Maintainer of the Informix FAQ Primary site (Beta Version) http://www.smooth1.demon.co.uk Official site http://www.iiug.org/techinfo/faq/faq_top.html I see you standin', Standin' on your own, It's such a lonely place for you, For you to be If you need a shoulder, Or if you need a friend, I'll be here standing, Until the bitter end... So don't chastise me Or think I, I mean you harm... All I ever wanted Was for you To know that I care