2011-02-10(@tsatoppejp)
•    :•twitter: tsatoppejp•Facebook: tsatoppejp•    : 2006             2010
The More with symfony book                              ... ORM          Propel   Doctrine       PHP PHP5.3
Doctrine                               ...           5.2.5         PHP              Doctrine                   PHP
...• PHP                             (PHP5.3       )• Doctrine•                  Doctrine   (             )
$a = new stdClass();$a->self = $a;//               $a refcount   2   1   a   (   )unset($a);// $a refcount    1//         ...
Doctrine free()$a = new stdClass();$a->self = $a;$a->self = null;// unset()unset($a);// $a refcount   0//                 ...
Doctrine•                4682     Symfony1.4.3   task   sfDoctrinePager    100•                         Doctrine::HYDRATE_...
Doctrine$pager = new sfDoctrinePager(User, 100);$q = Doctrine_Query::create()->from(User u);$pager->setPage(1);$pager->set...
Doctrine40000000                       PHP5.2.14 Object                       PHP5.2.14 Object free()                     ...
Doctrine     PHP5.2.14 Object                                                   7.498278141PHP5.2.14 Object free()        ...
• $user->free()•                            Doctrine::HYDRATE_ARRAY(      )                                               ...
Doctrine2$dql = "SELECT u FROM EntitiesUser u";$query = $em->createQuery($dql);$iterableResult = $query->iterate();$i = 0;...
Doctrine215000000                       Doctrine2                       Doctrine2 clear()1125000075000003750000      0    ...
Doctrine2       Doctrine2                                                 2.8972089291 Doctrine2 clear()        2.89448618...
40000000                  PHP5.2.14 Object                  PHP5.2.14 Object free()                  PHP5.2.14 Array      ...
PHP5.2.14 Object                                                          7.498278141PHP5.2.14 Object free()              ...
• Doctrine1       PHP5.3• Doctrine1       select    free()• Doctrine2       clear()                        (              ...
Doctrine1$pager = new sfDoctrinePager(User, 100);$q = Doctrine_Query::create()->from(User u);$pager->setPage(1);$pager->se...
Doctrineのメモリーリークについて
Doctrineのメモリーリークについて
Upcoming SlideShare
Loading in …5
×

Doctrineのメモリーリークについて

4,251 views

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
4,251
On SlideShare
0
From Embeds
0
Number of Embeds
105
Actions
Shares
0
Downloads
10
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Doctrineのメモリーリークについて

  1. 1. 2011-02-10(@tsatoppejp)
  2. 2. • :•twitter: tsatoppejp•Facebook: tsatoppejp• : 2006 2010
  3. 3. The More with symfony book ... ORM Propel Doctrine PHP PHP5.3
  4. 4. Doctrine ... 5.2.5 PHP Doctrine PHP
  5. 5. ...• PHP (PHP5.3 )• Doctrine• Doctrine ( )
  6. 6. $a = new stdClass();$a->self = $a;// $a refcount 2 1 a ( )unset($a);// $a refcount 1// $a (PHP5.3 )
  7. 7. Doctrine free()$a = new stdClass();$a->self = $a;$a->self = null;// unset()unset($a);// $a refcount 0// $a// Doctrine free()
  8. 8. Doctrine• 4682 Symfony1.4.3 task sfDoctrinePager 100• Doctrine::HYDRATE_ARRAY( )• PHP PHP 5.2.14 PHP 5.3.5• AWS EC2 small instance(32 1.7 GB 1 160GB )
  9. 9. Doctrine$pager = new sfDoctrinePager(User, 100);$q = Doctrine_Query::create()->from(User u);$pager->setPage(1);$pager->setQuery($q);$pager->init();while ($pager->getResults()->count()) { foreach ($pager->getResults() as $user) { $user_id = $user->getId(); // foreach ($pager->getResults(Doctrine::HYDRATE_ARRAY) as $user) { // $user_id = $user[‘id’]; } $page = $pager->getPage(); $page++; $pager->setPage($page); ...}
  10. 10. Doctrine40000000 PHP5.2.14 Object PHP5.2.14 Object free() PHP5.2.14 Array PHP5.3.5 Object PHP5.3.5 Object free() PHP5.3.5 Array300000002000000010000000 0 100 300 500 700 900 1100 1300 1500 1700 1900 2100 2300 2500 2700 2900 3100 3300 3500 3700 3900 4100 4300 4500 4700
  11. 11. Doctrine PHP5.2.14 Object 7.498278141PHP5.2.14 Object free() 8.2011160851 PHP5.2.14 Array 6.247120142 PHP5.3.5 Object 7.4590570927 PHP5.3.5 Object free() 7.5311901569 PHP5.3.5 Array 5.9629459381 0 2.25 4.50 6.75 9.00 ( )
  12. 12. • $user->free()• Doctrine::HYDRATE_ARRAY( ) Doctrine::HYDRATE_ARRAY ( )• $user->free() unset($user) gc_collect_cycles() Doctrine1 PHP5.2 5.3
  13. 13. Doctrine2$dql = "SELECT u FROM EntitiesUser u";$query = $em->createQuery($dql);$iterableResult = $query->iterate();$i = 0;foreach($iterableResult AS $row) { // PDOStatement::fetch()    $user_id = $row[0]->getId();   ...    if ($i % 150 == 0) {        $em->flush();        $em->clear();    }    $i++;}
  14. 14. Doctrine215000000 Doctrine2 Doctrine2 clear()1125000075000003750000 0 100 300 500 700 900 1100 1300 1500 1700 1900 2100 2300 2500 2700 2900 3100 3300 3500 3700 3900 4100 4300 4500 4700
  15. 15. Doctrine2 Doctrine2 2.8972089291 Doctrine2 clear() 2.8944861889 0.003 2.89300 2.89425 2.89550 2.89675 2.89800 ( )
  16. 16. 40000000 PHP5.2.14 Object PHP5.2.14 Object free() PHP5.2.14 Array PHP5.3.5 Object PHP5.3.5 Object free() PHP5.3.5 Array Doctrine2 Doctrine2 clear()300000002000000010000000 0 100 300 500 700 900 1100 1300 1500 1700 1900 2100 2300 2500 2700 2900 3100 3300 3500 3700 3900 4100 4300 4500 4700
  17. 17. PHP5.2.14 Object 7.498278141PHP5.2.14 Object free() 8.2011160851 PHP5.2.14 Array 6.247120142 PHP5.3.5 Object 7.4590570927 PHP5.3.5 Object free() 7.5311901569 PHP5.3.5 Array 5.9629459381 Doctrine2 2.8972089291 Doctrine2 clear() 2.8944861889 0 2.25 4.50 6.75 9.00 ( )
  18. 18. • Doctrine1 PHP5.3• Doctrine1 select free()• Doctrine2 clear() ( )• Doctrine2
  19. 19. Doctrine1$pager = new sfDoctrinePager(User, 100);$q = Doctrine_Query::create()->from(User u);$pager->setPage(1);$pager->setQuery($q);$pager->init();while ($pager->getResults()->count()) { foreach ($pager->getResults() as $user) { $command = sprintf(“/path/to/symfony execute:task %d”, $user->getId()); `$command`; // $user->free(); } $page = $pager->getPage(); $page++; $pager->setPage($page); ...}

×