Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-1682

EntityManager::clear() not working as expected.

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Critical Critical
    • Resolution: Incomplete
    • Affects Version/s: 2.1.6
    • Fix Version/s: None
    • Component/s: ORM
    • Security Level: All
    • Labels:
      None
    • Environment:
      Ubuntu 11.10
      Symfony 2

      Description

      I've been reading Doctrine2 Batch Processing documentation.
      I've a simplified the code and made a sample where I'm using a Repository inside the loop:

       
      for ($i=1; $i<=10000; ++$i) {
           $user = $this->_em->getRepository('some user class')->find($i);
           $this->_em->clear();
      
           //Clear variables to ensure garbage collections     
           unset($user);
           $user = null;
      
      }
      

      I expect that this script will consume some constant memory in all iterations, but what happens is that every iteration raises memory consumption (more iterations, more memory).... i think that the clear method has some sort of memory leak.

      In my production environment (with complex script), i reach a memory limit exception even with 600MB limit... but if I clear the EntityManager on every iteration, shouldn't memory be freed?

      Sorry for my bad english.

        Activity

        German Caseres created issue -
        German Caseres made changes -
        Field Original Value New Value
        Description I've been reading Doctrine2 Batch Processing documentation.
        I've a simplified the code and made a sample where I'm using a Repository inside the loop:


        for ($i=1; $i<=10000; ++$i) {
             $user = $this->_em->getRepository('some user class')->find($i);
             $this->_em->clear();

             //Clear variables to ensure garbage collections
             unset($user);
             $user = null;

        }

        I expect that this script will consume some constant memory in all iterations, but what happens is that every iteration raises memory consumption (more iterations, more memory).... i think that the clear method has some sort of memory leak.

        In my production environment (with complex script), i reach a memory limit exception even with 600MB limit... but if I clear the EntityManager on every iteration, shouldn't memory be freed?


        Sorry for my bad english.

        I've been reading Doctrine2 Batch Processing documentation.
        I've a simplified the code and made a sample where I'm using a Repository inside the loop:

        {code}
        for ($i=1; $i<=10000; ++$i) {
             $user = $this->_em->getRepository('some user class')->find($i);
             $this->_em->clear();

             //Clear variables to ensure garbage collections
             unset($user);
             $user = null;

        }
        {code}

        I expect that this script will consume some constant memory in all iterations, but what happens is that every iteration raises memory consumption (more iterations, more memory).... i think that the clear method has some sort of memory leak.

        In my production environment (with complex script), i reach a memory limit exception even with 600MB limit... but if I clear the EntityManager on every iteration, shouldn't memory be freed?


        Sorry for my bad english.

        Benjamin Eberlei made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Incomplete [ 4 ]
        Benjamin Eberlei made changes -
        Workflow jira [ 13497 ] jira-feedback [ 15256 ]
        Benjamin Eberlei made changes -
        Workflow jira-feedback [ 15256 ] jira-feedback2 [ 17120 ]
        Benjamin Eberlei made changes -
        Workflow jira-feedback2 [ 17120 ] jira-feedback3 [ 19373 ]

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            German Caseres
          • Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: