RE: memory leak in DBI XS bootstrap code



I don't see what you mean in the "INSTALL" that comes with perl 5.8.0 (that's what we're using).
The file called INSTALL in the perl source code directory.

That I knew. What are the special instructions that I'm supposed to find there? Am I supposed to build it with debugging? Can you specify what special configuration exactly you meant that I should use?

I've no time, sorry. You'll have to scratch this itch yourself (or hope that someone else has the same itch.)

It looks like the leak in boot_DBI is on purpose:
/* Remember the last handle used. BEWARE! Sneaky stuff here! */
/* We want a handle reference but we don't want to increment */
/* the handle's reference count and we don't want perl to try */
/* to destroy it during global destruction. Take care! */
DBI_UNSET_LAST_HANDLE; /* ensure setup the correct way */
Why is this being done, and does anyone have a way to fix it? Why don't we want perl to destroy it? Me, that's exactly what I want.

Still looking into the other leak in _install_method... any pointers still appreciated... Thanks for your help so far, Tim.

-edan

-----Original Message-----
From: Tim Bunce [mailto:Tim.Bunce@xxxxxxxxx]
Sent: Thursday, June 29, 2006 14:47
To: Ephraim Dan
Cc: dbi-users@xxxxxxxx
Subject: Re: memory leak in DBI XS bootstrap code

Try building perl with options to make valgrind leak tracing more
effective (see perl's INSTALL file). That may help you pinpoint
the problem.

Tim.

On Thu, Jun 29, 2006 at 04:33:40AM -0700, Ephraim Dan wrote:
I am experiencing what I believe to be a memory leak in the DBI
bootstrap code. This is a problem for me because I am embedding perl in a
long-running program, and DBI is being loaded over and over, so my program
grows and grows.

The problem appears to be in the following routines:

boot_DBI (in /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-
multi/auto/DBI/DBI.so)
XS_DBI__install_method (in /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-
thread-multi/auto/DBI/DBI.so)

I am using DBI 1.51

The tool "valgrind" (http://valgrind.org <http://valgrind.org/> ) can be used to reproduce the
leak using the following code:

---
File: embed_test.c
---

#include <EXTERN.h> /* from the Perl distribution */
#include <perl.h> /* from the Perl distribution */

static PerlInterpreter *my_perl; /*** The Perl interpreter ***/
EXTERN_C void xs_init (pTHX); /*** init dyn. loading ***/

int main(int argc, char **argv, char **env)
{
char *embedding[] = { "", "-e", "0" };
my_perl = perl_alloc();
perl_construct(my_perl);
perl_parse(my_perl, xs_init, 3, embedding, (char **)NULL);
PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
perl_run(my_perl);
eval_pv("use DBI", TRUE);
perl_destruct(my_perl);
perl_free(my_perl);
}

---
File: Makefile
---

CC_OPTS = $(shell perl -MExtUtils::Embed -e ccopts)
LD_OPTS = $(shell perl -MExtUtils::Embed -e ldopts)

EXE = embed_test

$(EXE): xsinit.o embed_test.o
gcc -o $(EXE) embed_test.o xsinit.o $(LD_OPTS)

embed_test.o: embed_test.c
gcc -c embed_test.c $(CC_OPTS)

xsinit.o: xsinit.c
gcc -c xsinit.c $(CC_OPTS)

xsinit.c:
perl -MExtUtils::Embed -e xsinit -- -o xsinit.c

clean:
rm -f *.o xsinit.c $(EXE)

---
EOF
---

Can anyone suggest a fix for this? I'd be more than willing to take a
patch to DBI 1.51 as soon as someone has one.

Thanks,
Ephraim Dan




Relevant Pages

  • RE: memory leak in DBI XS bootstrap code
    ... This is why I love the perl community - you're willing to help even though you don't have time, since you care about your code, and that other people can benefit from it. ... I just ran valgrind with your fix - there seems to still be a leak. ... memory leak in DBI XS bootstrap code ...
    (perl.dbi.users)
  • RE: memory leak in DBI XS bootstrap code
    ... I have created the following patch, which appears to fix all of the leaks. ... I am willing to use this patch if you approve it, until a new DBI is available with the fixes. ... I just ran valgrind with your fix - there seems to still be a leak. ... You can build perl ...
    (perl.dbi.users)
  • Re: memory leak in DBI XS bootstrap code
    ... The file called INSTALL in the perl source code directory. ... I don't believe that's a leak. ... without telling perl its a reference. ... memory leak in DBI XS bootstrap code ...
    (perl.dbi.users)
  • Re: Perl 6 DBI API ideas
    ... Though I didn't raise my hand when you asked for people to contribute to a DBI module for Perl 6, I've had some ideas that I thought about sharing. ... I would also love to see some standardization on the driver names ("mysql" when it's normally written ... DBI is supposed to be query language agnostic, even if SQL is the most commonly used group of languages, and if a user can declare this explicitly, it saves the driver from having to guess what they were given, which might be ambiguous. ...
    (perl.dbi.users)
  • Problem of DBI build
    ... I installed Oracle Application Server 4.0.8.2 included perl module. ... I need to installe DBI and DBD::Oracle module. ... You can install them any time after installing the DBI. ... line 318: error 1705: Function prototypes are an ANSI feature. ...
    (perl.dbi.users)