#16794 closed enhancement (invalid)
pomo/streams.php str_split() suggestion ?
Reported by: | mrasnika | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | minor | Version: | 3.1 |
Component: | Performance | Keywords: | |
Focuses: | Cc: |
Description
Hi, just passing along an idea that was suggested to me: we have a log which crashes with this --
Fatal error: Out of memory (allocated 23855104) (tried to allocate 9 bytes) in /var/www/html/wp-includes/pomo/streams.php on line 86
If you look at that line:
http://core.trac.wordpress.org/browser/tags/3.1/wp-includes/pomo/streams.php#L86
you will see that it is a simple str_split(). How about if the $string argument is passed by reference ? The problem as it is explained to me is that right now the $string argument is passed by value, e.g. it is copied, so if this is a large string, it is going to take double space when it is used as an argument; instead if it is used as an argument passed by reference it will not take any extra space at all.
What do you think, would this help POMO_Reader::str_split() work with large strings ?
Change History (7)
#1
@
14 years ago
- Summary changed from pomo/streams.php suggestion ? to pomo/streams.php str_split() suggestion ?
#4
in reply to:
↑ 2
;
follow-up:
↓ 5
@
14 years ago
Replying to mrasnika:
It seems that this "optimization" is not going to help at all since all arguments are passed by reference UNTIL/UNLESS they are modified:
PHP already optimises it - variables are assigned using copy-on-write, and objects are passed by reference
http://stackoverflow.com/questions/496669/are-php-strings-immutable
And as it's copy on write, it's even counter-productive to pass by reference to built-in functions as this does even increase the memory usage.
If you need to be able to use more than 256MB of memory, you can use the working patch 13847.patch (Related: #13847) which replaces the hard-encoded memory limit value with a configure-able constant.
However if you're looking for memory optimizations for pomo, extending classes could be overwrite parent functions and access their resources more optimized.
A review of of the composition of the final objects might reveal some structural benefits as well, AFAIK POMO tries to combine single and multibyte string operations with string- or file-io.
But that's structural and needs a refactoring plus testing if it really helps. So a lot of work.
#5
in reply to:
↑ 4
@
13 years ago
- Keywords close added
Replying to hakre:
If you need to be able to use more than 256MB of memory, you can use the working patch 13847.patch (Related: #13847) which replaces the hard-encoded memory limit value with a configure-able constant.
According to the description, it's about 24 MB allocated, not 256 MB. I'd suggest closing as invalid, since the default memory limit in wp_initial_constants()
is 32 MB.
It seems that this "optimization" is not going to help at all since all arguments are passed by reference UNTIL/UNLESS they are modified:
http://stackoverflow.com/questions/496669/are-php-strings-immutable