Make WordPress Core

Opened 8 years ago

Closed 7 years ago

#38588 closed defect (bug) (duplicate)

Improve PO object memory usage

Reported by: akirk's profile akirk Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: I18N Keywords: has-patch
Focuses: performance Cc:

Description

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
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)

Attachments (1)

38588.diff (2.1 KB) - added by akirk 8 years ago.

Download all attachments as: .zip

Change History (5)

#1 @ocean90
8 years ago

  • Version trunk deleted

Related/Duplicate: #37082

@akirk
8 years ago

This ticket was mentioned in Slack in #core-i18n by dd32. View the logs.


8 years ago

#3 @swissspidy
8 years ago

  • Keywords has-patch added

#4 @ocean90
7 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #37082.

Note: See TracTickets for help on using tickets.