Re: ESQL/C memory leak while working with LVARCHAR data (on Win32)
Posted in 2004
Thanks Abhishek it works. There was only one small problem, this function absent in client SDK header files :). But I had declared it manually accordingly to it's signature in latest documentation and all was fine. Abhishek Mathur <abhishek@us.ibm.com> wrote in message news:<c1o8d9$mme$1@terabinaries.xmission.com>... > Hello, > Please read the description of ifx_var_dealloc() again. It states > -- > ifx_var_dealloc() > The ifx_var_dealloc() function deallocates the memory that was allocated > for > the data buffer of a var binary host variable. > > Now, in the repro that you have provided, the data buffer maybe > deallocated, but the pointer is still not allocated. For this to > deallocate, we have another API - > ifx_var_freevar() > The ifx_var_freevar() function frees memory that has been allocated for > the > var binary and lvarchar pointer host variables. > > Please use the ifx_var_freevar() to deallocate the pointer > associated with lvarchar pointer host variable. For more information on > this, please refer to the latest ESQl/C Manual at - > http://publibfi.boulder.ibm.com/epubs/pdf/ct1uhna.pdf Page B-260. > > Simply adding ifx_var_freevar(&_value); within the loop, should > resolve the problem of the memory leak that you are getting and you should > not see the memory grow then. > > Thanks and Regards, > Abhi. > -------------------------------------------------------------------- > There are 10 kinds of people,,,,, > .... those who understand binary notations, and those who don't. > -------------------------------------------------------------------- > > > > > "Art S. Kagel" <kagel@bloomberg.net> > Sent by: owner-informix-list@iiug.org > 02/27/2004 07:26 AM > Please respond to > kagel > > > To > informix-list@iiug.org > cc > > Subject > Re: ESQL/C memory leak while working with LVARCHAR data (on Win32) > > > > > > > On Thu, 26 Feb 2004 15:00:31 -0500, Sergey V. Buturlakin wrote: > > Happens on Linux also. The memory usage grows to over 230MB. > > Art S. Kagel > > > While working with lvarchar data on win32 platform I'd trap on serious > > memory leak when such data is deallocated. Here is simple ESQL/C > program: > > > > #include <stdio.h> > > > > int main() > > { > > EXEC SQL BEGIN DECLARE SECTION; > > lvarchar *_value; > > EXEC SQL END DECLARE SECTION; > > char testdata[100]; > > int i; > > > > for (i = 0; i < 10000000; i++) > > { > > _value = 0; > > ifx_var_flag(&_value, 0); > > ifx_var_alloc(&_value, 101); > > ifx_var_setlen(&_value, 100); > > ifx_var_setdata(&_value, testdata, 100); ifx_var_init(&_value); > > ifx_var_dealloc(&_value); > > } > > > > getchar(); > > } > > > > When this program is running memory used by it's process grows extremely > > fast. > > Does anybody have any expirience with such problem ? > > > > P.S. Informix CSDK 2.80TC2 was used. > > > > -- > > With best regards > > BSV > > > sending to informix-list