Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leak on phalcon 3.0.0 and php 7.0 #12116

Closed
dimak08 opened this issue Aug 10, 2016 · 24 comments
Closed

Memory leak on phalcon 3.0.0 and php 7.0 #12116

dimak08 opened this issue Aug 10, 2016 · 24 comments
Labels
bug A bug report status: medium Medium
Milestone

Comments

@dimak08
Copy link

dimak08 commented Aug 10, 2016

Memory leak (?) on phalcon 3.0.0 and php 7.0 when using relations between models.

class ModelA extends Model
{
    public function initialize()
    {
        $this->hasMany("id", "File", "a_id", array('alias' => 'files', 'reusable' => false));
    }
}

class File extends Model
{
    public function initialize()
    {
        $this->belongsTo('a_id', 'ModelA', 'id', array('alias' => 'a', 'reusable' => true));
    }
}
  • Phalcon version: 3.0.0
  • PHP Version: 7.0.9
  • Operating System: Ubuntu 16.04
  • Installation type: installing via package manager
  • Server: Nginx + php-fpm
$files = with $a->getFiles() // 2k records
echo memory_get_usage() // 164 MB
  • Phalcon version: 3.0.0
  • PHP Version: 5.5.9
  • Operating System: Ubuntu 14.04
  • Installation type: installing via package manager
  • Server: Nginx + php-fpm
$files = with $a->getFiles() // 2k records
echo memory_get_usage() // 5 MB

sometimes I got this error:

2016/08/10 12:06:11 [error] 3959#3959: *273 FastCGI sent in stderr: "PHP message: PHP Warning:  Uncaught ReflectionException: Property id does not exist in /home/projects/new/cache/views-compiled/%%home%%projects%%new%%app%%view%%template%%model%%details.volt.compiled:844
Stack trace:
#0 [internal function]: ReflectionClass->getProperty('id')
#1 [internal function]: Phalcon\Mvc\Model->_isVisible('id')
#2 [internal function]: Phalcon\Mvc\Model->__set('id', '35851878')
#3 [internal function]: Phalcon\Mvc\Model::cloneResultMap(Object(projects\Mvc\Model\File), Array, NULL, 0, true)
#4 /home/projects/new/cache/views-compiled/%%home%%projects%%new%%app%%view%%template%%model%%details.volt.compiled(844): Phalcon\Mvc\Model\Resultset\Simple->current()
#5 [internal function]: unknown()
#6 [internal function]: Phalcon\Mvc\View\Engine\Volt->render('../app/View/tem...', Array, true)
#7 [internal function]: Phalcon\Mvc\View->_engineRender(Array, 'model/details', true, true, NULL)
#8 /home/projects/new/app/Application.php(176): Phalcon\Mvc\View->render('model', 'details', Array)
#9 /home/projects/new/app/Ap...
PHP message: PHP Stack trace:
PHP message: PHP   1. {main}() /home/projects/new/public/index.php:0
PHP message: PHP   2. Phalcon\Application->handle() /home/projects/new/public/index.php:262
PHP message: PHP   3. Phalcon\Application->prepareResponse() /home/projects/new/app/Application.php:222
PHP message: PHP   4. Phalcon\Mvc\View->render() /home/projects/new/app/Application.php:176
PHP message: PHP   5. Phalcon\Mvc\View->_engineRender() /home/projects/new/app/Application.php:176
PHP message: PHP   6. Phalcon\Mvc\View\Engine\Volt->render() /home/projects/new/app/Application.php:176
PHP message: PHP   7. Phalcon\Mvc\View\Engine\Volt->render() /home/projects/new/app/Application.php:176
PHP message: PHP   8. Phalcon\Mvc\Model\Resultset\Simple->current() /home/projects/new/cache/views-compiled/%%home%%projects%%new%%app%%view%%template%%model%%details.volt.compiled:844
PHP message: PHP   9. Phalcon\Mvc\Model::cloneResultMap() /home/projects/new/cache/views-compiled/%%home%%projects%%new%%ap
@Jurigag
Copy link
Contributor

Jurigag commented Aug 10, 2016

Provide valgrind log please, beacause memory_get_usage() doesn't necessary mean memory leak - it can mean just bad internal phalcon code for php 7 which should be fixed of course.

@dimak08
Copy link
Author

dimak08 commented Aug 10, 2016

After adding all properties in model -- no more problems with memory.
#12115 (comment)

But why is no such problem in php 5?

@Jurigag
Copy link
Contributor

Jurigag commented Aug 10, 2016

Beacause as far as i know there is some memory leak in phalcon and php 7, it's known by @andresgutierrez but good that you created an issue

@dimak08
Copy link
Author

dimak08 commented Aug 10, 2016

Sorry, I can't provide valgrind log (I can't install php with --enable-debug)
And code with problem:

$files = $a->getFiles();
foreach ($files as $file) {
}

@Jurigag
Copy link
Contributor

Jurigag commented Aug 10, 2016

Valgrind should still detect memory leaks, event without --enable-debug. But i think it's not needed beacause this problem is already known i think.

@sergeyklay
Copy link
Contributor

sergeyklay commented Aug 10, 2016

@dimak08
Are you pretty sure that in the second test Phalcon 3 + PHP 5, but not Phalcon 2 - PHP 5 ?

@sergeyklay sergeyklay modified the milestone: 3.0.1 Aug 10, 2016
@dimak08
Copy link
Author

dimak08 commented Aug 11, 2016

@sergeyklay
Yes, I'm sure what I use Phalcon 3 + PHP 5.5
2016-08-11 15 44 39

@Jurigag
I compiled php 7.0 on another server and after start my script I got notices from php about memory leaks.

index.php

$loader = new \Phalcon\Loader();
$di = new \Phalcon\Di\FactoryDefault();
$di->set('db', function () use ($di) {/**/});
class File extends \Phalcon\Mvc\Model
{
    public function getSource()
    {
        return 'files';
    }
    public function initialize()
    {
        $this->belongsTo('a', 'ModelA', 'id', array('alias' => 'a', 'reusable' => true));
    }
}
class ModelA extends \Phalcon\Mvc\Model
{
    public function getSource()
    {
        return 'a';
    }
    public function initialize()
    {
        $this->hasMany("id", "File", "a", array('alias' => 'files', 'reusable' => false));
    }
}
$a = ModelA::findFirst(['id = :id:', 'bind' => ['id' => 5014387]]);
$files = $a->getFiles();
foreach ($files as $f) {};
echo memory_get_usage() . "\n";

response:

44690309
[Thu Aug 11 15:19:28 2016]  Script:  '/home/dimak/projects/index.php'
/home/dimak/php-7.0.9/Zend/zend_objects.c(162) :  Freeing 0xB4A635A0 (136 bytes), script=/home/dimak/projects/index.php
Last leak repeated 63 times
[Thu Aug 11 15:19:28 2016]  Script:  '/home/dimak/projects/index.php'
/home/dimak/php-7.0.9/Zend/zend_objects.c(162) :  Freeing 0xADA0A000 (136 bytes), script=/home/dimak/projects/index.php
Last leak repeated 424 times
[Thu Aug 11 15:19:28 2016]  Script:  '/home/dimak/projects/index.php'
/home/dimak/php-7.0.9/Zend/zend_objects.c(162) :  Freeing 0xAD809000 (136 bytes), script=/home/dimak/projects/index.php
Last leak repeated 424 times
[Thu Aug 11 15:19:28 2016]  Script:  '/home/dimak/projects/index.php'
/home/dimak/php-7.0.9/Zend/zend_objects.c(162) :  Freeing 0xAD603000 (136 bytes), script=/home/dimak/projects/index.php
Last leak repeated 424 times
[Thu Aug 11 15:19:28 2016]  Script:  '/home/dimak/projects/index.php'
/home/dimak/php-7.0.9/Zend/zend_objects.c(162) :  Freeing 0xAD401000 (136 bytes), script=/home/dimak/projects/index.php
Last leak repeated 449 times
[Thu Aug 11 15:19:28 2016]  Script:  '/home/dimak/projects/index.php'
/home/dimak/php-7.0.9/Zend/zend_objects.c(162) :  Freeing 0xAD21B000 (136 bytes), script=/home/dimak/projects/index.php
Last leak repeated 424 times
[Thu Aug 11 15:19:28 2016]  Script:  '/home/dimak/projects/index.php'
/home/dimak/php-7.0.9/Zend/zend_objects.c(162) :  Freeing 0xAD01B000 (136 bytes), script=/home/dimak/projects/index.php
Last leak repeated 424 times
[Thu Aug 11 15:19:28 2016]  Script:  '/home/dimak/projects/index.php'
/home/dimak/php-7.0.9/Zend/zend_objects.c(162) :  Freeing 0xACE18000 (136 bytes), script=/home/dimak/projects/index.php
Last leak repeated 424 times
[Thu Aug 11 15:19:28 2016]  Script:  '/home/dimak/projects/index.php'
/home/dimak/php-7.0.9/Zend/zend_objects.c(162) :  Freeing 0xACC15000 (136 bytes), script=/home/dimak/projects/index.php
Last leak repeated 424 times
[Thu Aug 11 15:19:28 2016]  Script:  '/home/dimak/projects/index.php'
/home/dimak/php-7.0.9/Zend/zend_objects.c(162) :  Freeing 0xACA12000 (136 bytes), script=/home/dimak/projects/index.php
Last leak repeated 424 times
[Thu Aug 11 15:19:28 2016]  Script:  '/home/dimak/projects/index.php'
/home/dimak/php-7.0.9/Zend/zend_objects.c(162) :  Freeing 0xAC80E000 (136 bytes), script=/home/dimak/projects/index.php
Last leak repeated 424 times
[Thu Aug 11 15:19:28 2016]  Script:  '/home/dimak/projects/index.php'
/home/dimak/php-7.0.9/Zend/zend_objects.c(162) :  Freeing 0xAC60F000 (136 bytes), script=/home/dimak/projects/index.php
Last leak repeated 424 times
[Thu Aug 11 15:19:28 2016]  Script:  '/home/dimak/projects/index.php'
/home/dimak/php-7.0.9/Zend/zend_objects.c(162) :  Freeing 0xAC40C000 (136 bytes), script=/home/dimak/projects/index.php
Last leak repeated 424 times
[Thu Aug 11 15:19:28 2016]  Script:  '/home/dimak/projects/index.php'
/home/dimak/php-7.0.9/Zend/zend_objects.c(162) :  Freeing 0xAC208000 (136 bytes), script=/home/dimak/projects/index.php
Last leak repeated 424 times
[Thu Aug 11 15:19:28 2016]  Script:  '/home/dimak/projects/index.php'
/home/dimak/php-7.0.9/Zend/zend_objects.c(162) :  Freeing 0xAC006000 (136 bytes), script=/home/dimak/projects/index.php
Last leak repeated 424 times
[Thu Aug 11 15:19:28 2016]  Script:  '/home/dimak/projects/index.php'
/home/dimak/php-7.0.9/Zend/zend_objects.c(162) :  Freeing 0xABE03000 (136 bytes), script=/home/dimak/projects/index.php
Last leak repeated 449 times
[Thu Aug 11 15:19:28 2016]  Script:  '/home/dimak/projects/index.php'
/home/dimak/php-7.0.9/Zend/zend_objects.c(162) :  Freeing 0xABC1E000 (136 bytes), script=/home/dimak/projects/index.php
Last leak repeated 424 times
[Thu Aug 11 15:19:28 2016]  Script:  '/home/dimak/projects/index.php'
/home/dimak/php-7.0.9/Zend/zend_objects.c(162) :  Freeing 0xABA1A000 (136 bytes), script=/home/dimak/projects/index.php
Last leak repeated 424 times
[Thu Aug 11 15:19:28 2016]  Script:  '/home/dimak/projects/index.php'
/home/dimak/php-7.0.9/Zend/zend_objects.c(162) :  Freeing 0xAB817000 (136 bytes), script=/home/dimak/projects/index.php
Last leak repeated 424 times
[Thu Aug 11 15:19:28 2016]  Script:  '/home/dimak/projects/index.php'
/home/dimak/php-7.0.9/Zend/zend_objects.c(162) :  Freeing 0xAB614000 (136 bytes), script=/home/dimak/projects/index.php
Last leak repeated 424 times
[Thu Aug 11 15:19:28 2016]  Script:  '/home/dimak/projects/index.php'
/home/dimak/php-7.0.9/Zend/zend_objects.c(162) :  Freeing 0xAB419000 (136 bytes), script=/home/dimak/projects/index.php
Last leak repeated 424 times
[Thu Aug 11 15:19:28 2016]  Script:  '/home/dimak/projects/index.php'
/home/dimak/php-7.0.9/Zend/zend_objects.c(162) :  Freeing 0xAB216000 (136 bytes), script=/home/dimak/projects/index.php
Last leak repeated 229 times
=== Total 8844 memory leaks detected ===

zend_objects.c(162) is emalloc function in:

ZEND_API zend_object *zend_objects_new(zend_class_entry *ce)
{
        zend_object *object = emalloc(sizeof(zend_object) + zend_object_properties_size(ce));

        zend_object_std_init(object, ce);
        object->handlers = &std_object_handlers;
        return object;
}

Valgrind:

valgrind --tool=memcheck --log-file=php.log /opt/php-7.0/bin/php index.php

Response:

==26790== Memcheck, a memory error detector
==26790== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==26790== Using Valgrind-3.12.0.SVN and LibVEX; rerun with -h for copyright info
==26790== Command: /opt/php-7.0/bin/php index.php
==26790== Parent PID: 20567
==26790== 
==26790== 
==26790== HEAP SUMMARY:
==26790==     in use at exit: 782 bytes in 33 blocks
==26790==   total heap usage: 39,322 allocs, 39,289 frees, 3,216,002 bytes allocated
==26790== 
==26790== LEAK SUMMARY:
==26790==    definitely lost: 0 bytes in 0 blocks
==26790==    indirectly lost: 0 bytes in 0 blocks
==26790==      possibly lost: 0 bytes in 0 blocks
==26790==    still reachable: 782 bytes in 33 blocks
==26790==         suppressed: 0 bytes in 0 blocks
==26790== Reachable blocks (those to which a pointer was found) are not shown.
==26790== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==26790== 
==26790== For counts of detected and suppressed errors, rerun with: -v
==26790== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

Valgrind:

USE_ZEND_ALLOC=0 valgrind --tool=memcheck --leak-check=full --show-leak-kinds=all --log-file=php-3.log /opt/php-7.0/bin/php index.php

Response:

==26800== Memcheck, a memory error detector
==26800== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==26800== Using Valgrind-3.12.0.SVN and LibVEX; rerun with -h for copyright info
==26800== Command: /opt/php-7.0/bin/php index.php
==26800== Parent PID: 20567
==26800== 
==26800== 
==26800== HEAP SUMMARY:
==26800==     in use at exit: 1,203,534 bytes in 8,877 blocks
==26800==   total heap usage: 784,623 allocs, 775,746 frees, 54,431,592 bytes allocated
==26800== 
==26800== 104 bytes in 1 blocks are definitely lost in loss record 27 of 29
==26800==    at 0x402C27C: malloc (vg_replace_malloc.c:299)
==26800==    by 0x84AF616: _emalloc (zend_alloc.c:2446)
==26800==    by 0x850F496: zend_objects_new (zend_objects.c:162)
==26800==    by 0x84DC757: _object_and_properties_init (zend_API.c:1301)
==26800==    by 0x84DC7EB: _object_init_ex (zend_API.c:1316)
==26800==    by 0xB7F2A01: ???
==26800==    by 0x8522513: ZEND_DO_FCALL_SPEC_HANDLER (zend_vm_execute.h:842)
==26800==    by 0x85216F4: execute_ex (zend_vm_execute.h:414)
==26800==    by 0x85217A9: zend_execute (zend_vm_execute.h:458)
==26800==    by 0x84D88B8: zend_execute_scripts (zend.c:1427)
==26800==    by 0x8469CDE: php_execute_script (main.c:2494)
==26800==    by 0x8576B6E: do_cli (php_cli.c:974)
==26800== 
==26800== 1,202,648 bytes in 8,843 blocks are definitely lost in loss record 29 of 29
==26800==    at 0x402C27C: malloc (vg_replace_malloc.c:299)
==26800==    by 0x84AF616: _emalloc (zend_alloc.c:2446)
==26800==    by 0x850F496: zend_objects_new (zend_objects.c:162)
==26800==    by 0x84F8452: zend_default_exception_new_ex (zend_exceptions.c:204)
==26800==    by 0x84F85AA: zend_default_exception_new (zend_exceptions.c:233)
==26800==    by 0x84DC7B4: _object_and_properties_init (zend_API.c:1308)
==26800==    by 0x84DC7EB: _object_init_ex (zend_API.c:1316)
==26800==    by 0x84FB25F: zend_throw_exception (zend_exceptions.c:934)
==26800==    by 0x84FB2EF: zend_throw_exception_ex (zend_exceptions.c:958)
==26800==    by 0x82F4E3C: zim_reflection_class_getProperty (php_reflection.c:4280)
==26800==    by 0xB77C393: ???
==26800==    by 0xB777A7E: ???
==26800== 
==26800== LEAK SUMMARY:
==26800==    definitely lost: 1,202,752 bytes in 8,844 blocks
==26800==    indirectly lost: 0 bytes in 0 blocks
==26800==      possibly lost: 0 bytes in 0 blocks
==26800==    still reachable: 782 bytes in 33 blocks
==26800==         suppressed: 0 bytes in 0 blocks
==26800== Reachable blocks (those to which a pointer was found) are not shown.
==26800== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==26800== 
==26800== For counts of detected and suppressed errors, rerun with: -v
==26800== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)

@Jurigag
Copy link
Contributor

Jurigag commented Aug 11, 2016

Workaround for now is to add all properties to model as far as i know.

@nsossonko
Copy link
Contributor

I had the same memory leak even with all properties defined in the model, so not sure it works for the memory leak

@Jurigag
Copy link
Contributor

Jurigag commented Aug 11, 2016

Well i forgot to add that you need to add them as public i guess.

Actually you need setters i think as workaround for now:

https://github.com/phalcon/cphalcon/blob/master/phalcon/mvc/model.zep#L4171

@dimak08

Try to add properties with setters for now, then reflection shouldn't be used and memory leak not happening.

@sergeyklay
Copy link
Contributor

sergeyklay commented Aug 11, 2016

We'll try to fix it is as soon as it possible

@nsossonko
Copy link
Contributor

Well for me public properties is not an option as I need getters/setters under certain circumstances

@Jurigag
Copy link
Contributor

Jurigag commented Aug 11, 2016

@nsossonko I was mistaken, refresh page, if you have setters and getters then reflections shouldn't even be used at all.

@nsossonko
Copy link
Contributor

Well I do have getters and setters...but still see the increase in memory. I'd be interested to hear what others are experiencing with this...

@Jurigag
Copy link
Contributor

Jurigag commented Aug 11, 2016

Then the root of this is somewhere else and it's not related to this issue - you need to provide logs from valgrind or other mem analyzing software.

@Jurigag
Copy link
Contributor

Jurigag commented Aug 11, 2016

When i have setters so reflections are not hitted i don't have memory leak @nsossonko :

==4817== LEAK SUMMARY:
==4817==    definitely lost: 744 bytes in 21 blocks
==4817==    indirectly lost: 0 bytes in 0 blocks
==4817==      possibly lost: 464 bytes in 5 blocks
==4817==    still reachable: 119,160 bytes in 373 blocks
==4817==         suppressed: 0 bytes in 0 blocks
==4817== Reachable blocks (those to which a pointer was found) are not shown.
==4817== To see them, rerun with: --leak-check=full --show-leak-kinds=all
class Test2 extends Model
{
    protected $a0;

    protected $a1;

    protected $a2;

    protected $a3;

    protected $a4;

    protected $a5;

    protected $a6;

    protected $a7;

    protected $a8;

    protected $a9;

    protected $a10;

    protected $a11;

    protected $a12;

    /**
     * @return mixed
     */
    public function getA0()
    {
        return $this->a0;
    }

    /**
     * @param mixed $a0
     *
     * @return Test2
     */
    public function setA0($a0)
    {
        $this->a0 = $a0;

        return $this;
    }

    /**
     * @return mixed
     */
    public function getA1()
    {
        return $this->a1;
    }

    /**
     * @param mixed $a1
     *
     * @return Test2
     */
    public function setA1($a1)
    {
        $this->a1 = $a1;

        return $this;
    }

    /**
     * @return mixed
     */
    public function getA2()
    {
        return $this->a2;
    }

    /**
     * @param mixed $a2
     *
     * @return Test2
     */
    public function setA2($a2)
    {
        $this->a2 = $a2;

        return $this;
    }

    /**
     * @return mixed
     */
    public function getA3()
    {
        return $this->a3;
    }

    /**
     * @param mixed $a3
     *
     * @return Test2
     */
    public function setA3($a3)
    {
        $this->a3 = $a3;

        return $this;
    }

    /**
     * @return mixed
     */
    public function getA4()
    {
        return $this->a4;
    }

    /**
     * @param mixed $a4
     *
     * @return Test2
     */
    public function setA4($a4)
    {
        $this->a4 = $a4;

        return $this;
    }

    /**
     * @return mixed
     */
    public function getA5()
    {
        return $this->a5;
    }

    /**
     * @param mixed $a5
     *
     * @return Test2
     */
    public function setA5($a5)
    {
        $this->a5 = $a5;

        return $this;
    }

    /**
     * @return mixed
     */
    public function getA6()
    {
        return $this->a6;
    }

    /**
     * @param mixed $a6
     *
     * @return Test2
     */
    public function setA6($a6)
    {
        $this->a6 = $a6;

        return $this;
    }

    /**
     * @return mixed
     */
    public function getA7()
    {
        return $this->a7;
    }

    /**
     * @param mixed $a7
     *
     * @return Test2
     */
    public function setA7($a7)
    {
        $this->a7 = $a7;

        return $this;
    }

    /**
     * @return mixed
     */
    public function getA8()
    {
        return $this->a8;
    }

    /**
     * @param mixed $a8
     *
     * @return Test2
     */
    public function setA8($a8)
    {
        $this->a8 = $a8;

        return $this;
    }

    /**
     * @return mixed
     */
    public function getA9()
    {
        return $this->a9;
    }

    /**
     * @param mixed $a9
     *
     * @return Test2
     */
    public function setA9($a9)
    {
        $this->a9 = $a9;

        return $this;
    }

    /**
     * @return mixed
     */
    public function getA10()
    {
        return $this->a10;
    }

    /**
     * @param mixed $a10
     *
     * @return Test2
     */
    public function setA10($a10)
    {
        $this->a10 = $a10;

        return $this;
    }

    /**
     * @return mixed
     */
    public function getA11()
    {
        return $this->a11;
    }

    /**
     * @param mixed $a11
     *
     * @return Test2
     */
    public function setA11($a11)
    {
        $this->a11 = $a11;

        return $this;
    }

    /**
     * @return mixed
     */
    public function getA12()
    {
        return $this->a12;
    }

    /**
     * @param mixed $a12
     *
     * @return Test2
     */
    public function setA12($a12)
    {
        $this->a12 = $a12;

        return $this;
    }


}

$test = new Test2();
echo memory_get_usage(true).'<br>';
for ($i = 0; $i <= 12; $i++) {
    try {
        $test->__set("a$i", 'test');
    }
    catch (Exception $e)
    {}
}
echo memory_get_usage(true).'<br>';

But when we check for to example 1000 in loop then memory leak occurs, same as in OP.

You need to provide script to reproduce this another memory leak.

@sergeyklay
Copy link
Contributor

@dimak08 Could you please check the 3.0.x branch now?

@Jurigag
Copy link
Contributor

Jurigag commented Aug 13, 2016

I checked and it's fine for me.

@sergeyklay
Copy link
Contributor

@dimak08

@dimak08
Copy link
Author

dimak08 commented Aug 15, 2016

Hi @sergeyklay

Thanks,
Problem described above is resolved.

But I have another problem with memory.

while (true) {
    $model = ModelA::findFirst([
        'id = :id:',
        'bind' => ['id' => 5014387]
    ]);

    if ($counter == 1000) {
        echo bytes(memory_get_usage()) . "\n";
    }

    if ($counter == 2000) {
        echo bytes(memory_get_usage()) . "\n";
    }

    if ($counter == 3000) {
        echo bytes(memory_get_usage()) . "\n";
    }

    if ($counter == 4000) {
        echo bytes(memory_get_usage()) . "\n";
        die();
    }

    $counter++;
    $model = null;
}

php 5.5 + phalcon 3.0 from apt repository:

414.29 KB
414.35 KB
414.35 KB
414.35 KB

php 7.0.9 + phalcon 3.0 from git (branch 3.0.x commit 649f35c):

5.14 MB
9.83 MB
14.54 MB
19.2 MB

Adding/removing getter/setters/properties = nothing changes.

My mega slow server very long compile new version from sources for valgrind.
I attach log immediately after compilation.

@Jurigag
Copy link
Contributor

Jurigag commented Aug 15, 2016

You don't need to compile phalcon/php from soruces for using with valgrind. It should work as it is. Just there will be more information in log or php will detect memory leaks itself.

@dimak08
Copy link
Author

dimak08 commented Aug 15, 2016

@Jurigag
My default server have some problems with valgrind (I do not know what, just crash after run).
I have another server to to run valgrind (need recompile again).

valgrind-php.txt

Valgrind says that no memory leaks.

@sergeyklay
Copy link
Contributor

sergeyklay commented Aug 15, 2016

@dimak08 Hello. Thanks for answering. It seems to me this is another problem. Could you please open new issue with script to reproduce (model, table schema and this ^ test, valgrind report if any)? So that we can close this issue

@dimak08
Copy link
Author

dimak08 commented Aug 15, 2016

Ok, thanks

@dimak08 dimak08 closed this as completed Aug 15, 2016
@niden niden added bug A bug report status: medium Medium and removed Bug - Medium labels Dec 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug report status: medium Medium
Projects
None yet
Development

No branches or pull requests

6 participants