On Fri, Oct 26, 2001 at 02:29:20PM +0200, Hruska Pavel wrote:
> Hello,
> 
> I think there is memory leaking in DBI at least since 1.18. DBI not
> correctly releases memory if sql command is like  "INSERT INTO table1 SELECT
> * FROM table2 WHERE column01 = ?". If SQL command is without question mark
> "INSERT INTO table1 SELECT  * FROM table2 WHERE column01 = 1" everything is
> correct. 
> 
> I have called only prepare and finish method and allocated memory is still
> increasing (see example bellow).
> 
> I tested it on MS Windows NT 4.0 SP6 and HP-UX 11.00 and I used Informix DB
> server IDS2000 and MSSQL Server 7.0.  I have used DBD-Informix-1.00.PC1 and
> DBD-ADO-2.1. I have tested it in DBI 1.18 and 1.20.
> 
> Summary:
> correct  : "INSERT INTO table1 SELECT  * FROM table2 WHERE column01 = 1"  
> correct  : "SELECT  * FROM table2 WHERE column01 = ?"  
> correct  : "INSERT INTO test01 (column01) values (?)"
> incorrect  : "INSERT INTO table1 SELECT  * FROM table2 WHERE column01 = ?"  
> 
> Thanks in advance and best regards,

I suspect this is a bug in the drivers. They probably don't set the
Active flag for the insert statement (which is correct) but then
if Active isn't set they probably don't do sufficient clean-up when
the handle is destroyed.

Try adding a $sth->{Active} just before the finish (and/or instead of it).

Tim.

> Pavel Hruska
> 
> 
> Tables definition
> 
> CREATE TABLE test01 (
>   column01 int NOT NULL,
>   column02 char(10) NOT NULL
> )
> CREATE TABLE test02 (
>   column01 int NOT NULL,
>   column02 char(10) NOT NULL
> )
> 
> 
> use strict;
> use English;
> use DBI;
> 
> my $sql = "INSERT INTO test01 select * from test02 where column01 = ?";
> 
> my($database, $user, $password) = ('xhr_empty@orcela','dbuser1','dbuser1');
> 
> my $dbh  = DBI->connect("dbi:Informix:$database", $user, $password,  {
> RaiseError  => 1, PrintError  => 0,  AutoCommit  => 0, ChopBlanks  => 1,});
> # other datasource
> #my $dbh  =
> DBI->connect("dbi:ADO:Provider=sqloledb;Server=KAMBALA;Database=xmp_testPerl
> ;Trusted_Connection=yes");
> 
> die "DB connection failed, handle is (null). db: 'dbi:Informix:$database',
> user: '$user'\n" if !$dbh;
> 
> for (1..10000) {
>   my $sh = $dbh->prepare($sql);
>   $sh->finish;
> 
> }
> $dbh->disconnect;
> 
> 
> ***********************************
> ** HP-UX 11.00
> ***********************************
> 
> $ uname -a
> HP-UX orcela B.11.00 U 9000/800 573706537 unlimited-user license
> 
> $ perl -V
> Summary of my perl5 (revision 5.0 version 6 subversion 1) configuration:
>   Platform:
>     osname=hpux, osvers=11.00, archname=PA-RISC2.0
>     uname='hp-ux orcela b.11.00 u 9000800 573706537 unlimited-user license '
>     config_args='-Dcc=gcc -Dprefix=/opt/perl/5.6.1_dynamic'
>     hint=previous, useposix=true, d_sigaction=define
>     usethreads=undef use5005threads=undef useithreads=undef
> usemultiplicity=undef
>     useperlio=undef d_sfio=undef uselargefiles=undef usesocks=undef
>     use64bitint=undef use64bitall=undef uselongdouble=undef
>   Compiler:
>     cc='gcc', ccflags ='-D_HPUX_SOURCE -L/lib/pa1.1 -DUINT32_MAX_BROKEN
> -I/usr/local/include',
>     optimize='-O',
>     cppflags='-D_HPUX_SOURCE -L/lib/pa1.1 -DUINT32_MAX_BROKEN
> -I/usr/local/include'
>     ccversion='', gccversion='2.7.2.3', gccosandvers='hpux11.00'
>     intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
>     d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8
>     ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
> lseeksize=4
>     alignbytes=8, usemymalloc=y, prototype=define
>   Linker and Libraries:
>     ld='ld', ldflags =' -L/usr/local/lib'
>     libpth=/usr/local/lib /lib /usr/lib /usr/ccs/lib
>     libs=-lnsl -lnm -lndbm -ldld -lm -lc -lndir -lcrypt -lsec
>     perllibs=-lnsl -lnm -ldld -lm -lc -lndir -lcrypt -lsec
>     libc=/lib/libc.sl, so=sl, useshrplib=false, libperl=libperl.a
>   Dynamic Linking:
>     dlsrc=dl_hpux.xs, dlext=sl, d_dlsymun=undef, ccdlflags='-Wl,-E
> -Wl,-B,deferred '
>     cccdlflags='-fpic', lddlflags='-b -L/usr/local/lib'
>  
>  
> Characteristics of this binary (from libperl):
>   Compile-time options:
>   Built under hpux
>   Compiled at Jun  1 2001 15:47:28
>   @INC:
>     /opt/perl/5.6.1_dynamic/lib/5.6.1/PA-RISC2.0
>     /opt/perl/5.6.1_dynamic/lib/5.6.1
>     /opt/perl/5.6.1_dynamic/lib/site_perl/5.6.1/PA-RISC2.0
>     /opt/perl/5.6.1_dynamic/lib/site_perl/5.6.1
>     /opt/perl/5.6.1_dynamic/lib/site_perl
>     .
> 
> 
> 
> ***********************************
> ** MS Windows 2000
> ***********************************
> Summary of my perl5 (revision 5 version 6 subversion 1) configuration:
>   Platform:
>     osname=MSWin32, osvers=4.0, archname=MSWin32-x86
>     uname=''
>     config_args='undef'
>     hint=recommended, useposix=true, d_sigaction=undef
>     usethreads=undef use5005threads=undef useithreads=undef
> usemultiplicity=undef
>     useperlio=undef d_sfio=undef uselargefiles=undef usesocks=undef
>     use64bitint=undef use64bitall=undef uselongdouble=undef
>   Compiler:
>     cc='cl', ccflags ='-nologo -O1 -MD -DNDEBUG -DWIN32 -D_CONSOLE
> -DNO_STRICT   -DPERL_MSVCRT_READFIX',
>     optimize='-O1 -MD -DNDEBUG',
>     cppflags='-DWIN32'
>     ccversion='', gccversion='', gccosandvers=''
>     intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
>     d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=10
>     ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
> lseeksize=4
>     alignbytes=8, usemymalloc=n, prototype=define
>   Linker and Libraries:
>     ld='', ldflags ='-nologo -nodefaultlib -release
> -libpath:"l:\pgm\perl\5.6.1\perl\lib\CORE"  -machine:x86'
>     libpth=""C:\Program Files\Microsoft Visual Studio\VC98"\lib"
>     libs=  oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib
> comdlg32.lib advapi32.lib shell32.lib ole32.lib
> oleaut32.lib  netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib
> version.lib odbc32.lib odbccp32.lib msvcrt.lib
>     perllibs=  oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib
> comdlg32.lib advapi32.lib shell32.lib ole32.
> lib oleaut32.lib  netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib
> version.lib odbc32.lib odbccp32.lib msvcrt.lib
>     libc=msvcrt.lib, so=dll, useshrplib=yes, libperl=perl56.lib
>   Dynamic Linking:
>     dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
>     cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -release
> -libpath:"l:\pgm\perl\5.6.1\perl\lib\CORE"  -machine
> :x86'
> 
> 
> Characteristics of this binary (from libperl):
>   Compile-time options:
>   Built under MSWin32
>   Compiled at Jun  6 2001 20:02:09
>   @INC:
>     //MAKRELA/Shared/Pgm/Perl/5.6.1/perl/lib
>     //MAKRELA/Shared/Pgm/Perl/5.6.1/perl/site/lib
>     .
> 
> 
> 

Reply via email to