Unix Technical Forum

Re: ESQL/C memory leak while working with LVARCHAR data (on Win32)

This is a discussion on Re: ESQL/C memory leak while working with LVARCHAR data (on Win32) within the Informix forums, part of the Database Server Software category; --> Hello, Please read the description of ifx_var_dealloc() again. It states -- ifx_var_dealloc() The ifx_var_dealloc() function deallocates the memory that ...


Go Back   Unix Technical Forum > Database Server Software > Informix

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-19-2008, 09:35 PM
Abhishek Mathur
 
Posts: n/a
Default Re: ESQL/C memory leak while working with LVARCHAR data (on Win32)


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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-19-2008, 09:37 PM
Sergey V. Buturlakin
 
Posts: n/a
Default Re: ESQL/C memory leak while working with LVARCHAR data (on Win32)

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:24 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com