Hi Mark,

Thanks for the attention about this.

I did 2 tests: in one I removed ob_start from paintFall():

    function paintPass($message) {
        //removed ob_start();
        parent::paintPass($message);

        if ($this->_show_passes) {
            echo "<li class='pass'>\n";
            echo "<span>Passed</span> ";
            $breadcrumb = Set::filter($this->getTestList());
            array_shift($breadcrumb);
            echo implode(" -&gt; ", $breadcrumb);
            echo "<br />" . $this->_htmlEntities($message) . "\n";
            echo "</li>\n";
        }
    }


on the second I added a ob_end_flush() on the end:

    function paintPass($message) {
        ob_start();
        parent::paintPass($message);

        if ($this->_show_passes) {
            echo "<li class='pass'>\n";
            echo "<span>Passed</span> ";
            $breadcrumb = Set::filter($this->getTestList());
            array_shift($breadcrumb);
            echo implode(" -&gt; ", $breadcrumb);
            echo "<br />" . $this->_htmlEntities($message) . "\n";
            echo "</li>\n";
        }
        ob_end_flush();//by erico
    }


in both cases the result is the same: memory leak is gone as it will consume
less than 1k compared to the original 41k.

I don't know the impact of this change on assertEqual() functionaly, it is
just a test to check what is getting these 41k of memory.

Also I'm not familiar with memory usage on PHP and I'm not sure memory leak
behavior would crash a test execution due to memory problems, but I think it
should be investigated.

This is how I'm measuring memory usage on assertEqual (inside a testcase):

        $memory_get_usage_0 = memory_get_usage();

        $i = 1;
        $_loops = 300;

        while ($i <= $_loops) {

            $this->assertEqual(true, true);
            $i++;
        }

        $memory_get_usage = memory_get_usage();

        $memory_used = round(($memory_get_usage - $memory_get_usage_0) /
$_loops);


best regards

Erico


2008/9/3 mark_story <[EMAIL PROTECTED]>

>
> Erico,
>
> That is a little strange.  I'll look further into it.  If the leak is
> coming from paintPass() / paintFail() it should exist for every
> assertion not just assertEqual().
>
> -Mark
>
> On Sep 3, 1:43 pm, "Erico Franco" <[EMAIL PROTECTED]> wrote:
> > Hi Mark,
> >
> > Thanks for the reply.
> >
> > I've noticed the memory leak is caused due to call of ob_start() inside
> > cake/tests/lib/cake_reporter.php (paintPass($message) function) without
> any
> > ob_end_flush() call.
> >
> > In this way, successive assertEqual() calls will result in ob_start()
> calls
> > without any ob_end_flush() calls.
> >
> > According to PHP documentation, ob_start() and ob_end_flush() should be
> > called the same number of times:
> >
> > http://www.php.net/ob_start
> >
> > I'm not sure if ob_end_flush() is finally being called on the very end of
> > test suite execution, but each time an asserEqual is being called it is
> > getting 40K of memory.
> >
> > regards
> >
> > Erico
> >
> > 2008/9/3 mark_story <[EMAIL PROTECTED]>
> >
> >
> >
> > > On Sep 2, 2:25 pm, Defranco <[EMAIL PROTECTED]> wrote:
> > > > Hi,
> >
> > > > I just noticed that assertEqual() function (test suite) in cakephp
> 1.2
> > > > RC2 is consuming some memory inside test cases.
> >
> > > > I noticed that 300 assertEqual() executions, gets about 20 MB of PHP
> > > > free mem usage.
> >
> > > > It sounds a Memory Leak isn't it?
> >
> > > > I'm using cakephp 1.2.0.7296 RC2, and debug set to 1
> >
> > > > kind regards
> >
> > > > defranco
> >
> > > If there is a memory leak it most likely be related to SimpleTest
> > > rather than CakePHP as we do not maintain the SimpleTest libraries.  I
> > > haven't noticed any out of memory errors personally.  But perhaps the
> > > simpletest people might know something about it.
> >
> > > -Mark
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to