Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
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                             (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::H...
Doctrine

$pager = new sfDoctrinePager('User', 100);
$q = Doctrine_Query::create()->from('User u');
$pager->setPage(1);
$p...
Doctrine

40000000
                       PHP5.2.14 Object
                       PHP5.2.14 Object free()
                ...
Doctrine


     PHP5.2.14 Object                                                   7.498278141




PHP5.2.14 Object free()...
• $user->free()




•                            Doctrine::HYDRATE_ARRAY(      )
                                         ...
Doctrine2

$dql = "SELECT u FROM EntitiesUser u";
$query = $em->createQuery($dql);
$iterableResult = $query->iterate();
$i...
Doctrine2

15000000
                       Doctrine2
                       Doctrine2 clear()




11250000




7500000



...
Doctrine2


       Doctrine2                                                 2.8972089291




 Doctrine2 clear()        2....
40000000
                  PHP5.2.14 Object
                  PHP5.2.14 Object free()
                  PHP5.2.14 Array
  ...
PHP5.2.14 Object                                                          7.498278141



PHP5.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);
$...
Doctrineのメモリーリークについて
Doctrineのメモリーリークについて
Upcoming SlideShare
Loading in …5
×
Upcoming SlideShare
EC-CUBE Ver2とVer3 どう違う? 構築と運用の実際
Next
Download to read offline and view in fullscreen.

1

Share

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

Download to read offline

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all

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. Doctrine 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 30000000 20000000 10000000 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.498278141 PHP5.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. Doctrine2 15000000 Doctrine2 Doctrine2 clear() 11250000 7500000 3750000 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() 30000000 20000000 10000000 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.498278141 PHP5.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); ... }
  • HishikawaTakuro

    Aug. 6, 2015

Views

Total views

4,564

On Slideshare

0

From embeds

0

Number of embeds

105

Actions

Downloads

10

Shares

0

Comments

0

Likes

1

×