php/symfony/doctrine memory leak?

后端 未结 9 1690
旧时难觅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:39

    For a symfony task, I also faced to this issue and done following things. It worked for me.

    • Disable debug mode. Add following before db connection initialize

      sfConfig::set('sf_debug', false);
      
    • Set auto query object free attribute for db connection

      $connection->setAttribute(Doctrine_Core::ATTR_AUTO_FREE_QUERY_OBJECTS, true );
      
    • Free all object after use

      $object_name->free()
      
    • Unset all arrays after use unset($array_name)

    • Check all doctrine queries used on task. Free all queries after use. $q->free() (This is a good practice for any time of query using.)

    That's all. Hope it may help someone.

    0 讨论(0)
  • 2020-11-30 01:40

    For me , I've just initialized the task like that:

    // initialize the database connection
    $databaseManager = new sfDatabaseManager($this->configuration);
    $connection = $databaseManager->getDatabase($options['connection'])->getConnection();
    $config = ProjectConfiguration::getApplicationConfiguration('frontend', 'prod', true);
    sfContext::createInstance($config);
    

    (WITH PROD CONFIG)
    and use free() after a save() on doctrine's object

    the memory is stable at 25Mo

    memory_get_usage=26.884071350098Mo
    

    with php 5.3 on debian squeeze

    0 讨论(0)
  • 2020-11-30 01:41

    Periodically close and re-open the connection - not sure why but it seems PDO is retaining references.

    0 讨论(0)
提交回复
热议问题