php/symfony/doctrine memory leak?

后端 未结 9 1763
旧时难觅i
旧时难觅i 2020-11-30 00:34

I\'m having problems with a batch insertion of objects into a database using symfony 1.4 and doctrine 1.2.

My model has a certain kind of object called \"Sector\", e

9条回答
  •  遥遥无期
    2020-11-30 01:26

    Tried doing

    $cupo->save();
    $cupo->free();
    $cupo = null;
    

    (But substituting my code) And I'm still getting memory overflows. Any other ideas, SO?

    Update:

    I created a new environment in my databases.yml, that looks like:

    all:
      doctrine:
        class: sfDoctrineDatabase
        param:
          dsn: 'mysql:host=localhost;dbname=.......'
          username: .....
          password: .....
          profiler: false
    

    The profiler: false entry disables doctrine's query logging, that normally keeps a copy of every query you make. It didn't stop the memory leakage, but I was able to get about twice as far through my data importing as I was without it.

    Update 2

    I added

    Doctrine_Manager::connection()->setAttribute(Doctrine_Core::ATTR_AUTO_FREE_QUERY_OBJECTS, true ); 
    

    before running my queries, and changed

    $cupo = null;
    

    to

    unset($cupo);
    

    And now my script has been churning away happily. I'm pretty sure it will finish without running out of RAM this time.

    Update 3

    Yup. That's the winning combo.

提交回复
热议问题