[wp-trac] [WordPress Trac] #38588: Improve PO object memory usage

WordPress Trac noreply at wordpress.org
Mon Oct 31 10:38:30 UTC 2016


#38588: Improve PO object memory usage
--------------------------+-----------------------------
 Reporter:  akirk         |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  I18N          |    Version:  trunk
 Severity:  normal        |   Keywords:
  Focuses:  performance   |
--------------------------+-----------------------------
 Because of two uses of `create_function()` the memory usage of the PO
 object is inefficient, especially if loading multiple PO files.
 Additionally, when destroying the object, PHP leaks memory.

 {{{#!php
 <?php
 include __DIR__ . '/src/wp-includes/pomo/po.php';
 $po = new PO;
 echo 'new PO: '; var_dump( memory_get_usage() );
 $po->import_from_file( __DIR__ . '/wp-dev-de.po' );
 echo 'import_from_file: '; var_dump( memory_get_usage() );
 $po->import_from_file( __DIR__ . '/wp-dev-de.po' );
 echo 'import_from_file: '; var_dump( memory_get_usage() );
 $po->import_from_file( __DIR__ . '/wp-dev-de.po' );
 echo 'import_from_file: '; var_dump( memory_get_usage() );
 $po->import_from_file( __DIR__ . '/wp-dev-de.po' );
 echo 'import_from_file: '; var_dump( memory_get_usage() );
 $po->import_from_file( __DIR__ . '/wp-dev-de.po' );
 echo 'import_from_file: '; var_dump( memory_get_usage() );
 unset( $po );
 echo 'unset: '; var_dump( memory_get_usage() );
 }}}

 Output:
 {{{
 PHP 7.0.12 pre-patch
 new PO: int(492024)
 import_from_file: int(7279376)
 import_from_file: int(11243456)
 import_from_file: int(15138920)
 import_from_file: int(18954640)
 import_from_file: int(22767864)
 unset: int(19740920)

 PHP 7.0.12 post-patch
 new PO: int(491968)
 import_from_file: int(3413984)
 import_from_file: int(3545688)
 import_from_file: int(3546504)
 import_from_file: int(3547320)
 import_from_file: int(3548136)
 unset: int(521192)

 PHP 5.6.27 pre-patch
 new PO: int(398576)
 import_from_file: int(6461328)
 import_from_file: int(9305400)
 import_from_file: int(12115920)
 import_from_file: int(14913160)
 import_from_file: int(17712200)
 unset: int(14551448)

 PHP 5.6.27 post-patch
 new PO: int(402048)
 import_from_file: int(3652016)
 import_from_file: int(3652952)
 import_from_file: int(3653936)
 import_from_file: int(3654920)
 import_from_file: int(3655904)
 unset: int(606152)
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/38588>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list