Hey again

Tim answered to this problem yesterday but I didn't understand his answer
till now. The database handler stores in ChildHandles a list of all created
handles. This list is only emptied when $dbh looses scope.

The count didn't appear in my standalone test because it was
ill-implemented. Fixed it and the leak is there as well.

Where, not a leak, but a problem I need to solve.

At the moment I might do:
   $dbh->{ChildHandles} = [];

I am afraid of what might happen doing this. But as the docs say on older
Perl versions is attribute is undef, there should be no problems.

Ideas?

Alberto (aka ambs)



On Tue, May 7, 2013 at 4:11 PM, Alberto Simões <hashas...@gmail.com> wrote:

> I just forgot to explain how to run the Dancer app. Probably easier to use
> this app: http://paste.perldancer.org/1nX0n7dg6abTJ
>
> Also, the test with only DBI and no Dancer here:
> http://paste.perldancer.org/uzagWiCYXUsj
> that doesn't "leak" anything.
>
> mje_ on IRC did some experiments and found out that when using
> prepare_cached the scalar count doesn't change.
>
> But then, strange enough to have prepare leaking inside dancer, and not
> outside. :-|
>
> Cheers
> Alberto (aka ambs)
>
>
>
> On Tue, May 7, 2013 at 1:36 PM, Alberto Simões <hashas...@gmail.com>wrote:
>
>> Hello
>>
>> I am experiencing a behavior when using DBI inside Dancer that seems to
>> result on SCALAR leaks, but only when running inside Dancer.
>>
>> To help diagnosing I did a couple of tests that I try to explain below.
>>
>> First, I developed a sample small application in Dancer. It is available
>> (temporarily) in http://paste.perldancer.org/2yIABT6Yreh5T. Basically,
>> it has two routes. One that calls Devel::Gladiator and dumps the count for
>> each type of variables currently available, and another route that returns
>> OK. This route has a prepare statement (line 27) that is my problem.
>>
>> If I comment that line, and test calling the main route different times
>> (calling the arena between calls) I get the result in
>> http://paste.perldancer.org/sWhBrp2rh1lq. Basically, first 5 hits are
>> discarded, just to make sure all variables and caches prepared by Dancer
>> are filled in, and then I call the main route 100 times. You might notice
>> the amount of scalars rarely changes, and at the end, the summary is
>> negative (less two scalars than the amount we had when beginning the test).
>>
>> If I uncomment, then I get http://paste.perldancer.org/1mjhfOfwxEJxf,
>> where you might notice almost each call increments a SCALAR into memory. At
>> the end, the summary is 97 wasted scalars (almost the same number of hits).
>>
>> Although I imagine DBI does some kind of cache, it is weird it stores 97
>> copies for the same query. Nevertheless, I tried a similar approach without
>> Dancer, and NO SCALAR gets lost at all.
>>
>> Also, tried to do, in the same route, two prepares, and the number of
>> lost scalars doubles. If I do only one prepare but two execute/fetch, I get
>> only one scalar lost.
>>
>> So, this is something about Dancer and DBI together. But I have no idea
>> of what might be going on.
>>
>>
>> If you need some more details, or that I run some test, please poke me at
>> #dbi on irc.perl.org (ambs).
>>
>> Thanks,
>> Alberto (aka ambs)
>>
>> --
>> Alberto Simões
>>
>
>
>
> --
> Alberto Simões
>



-- 
Alberto Simões

Reply via email to