I’ve discussed with a friend the effect on memory of assigning strings by reference (or by value) within PHP5. There is a false belief about it: I’ve just written a short script that, using memory_get_peak_usage and memory_get_usage, reports the memory used by emalloc in the following case
$a = fit_the_string();
$b = fit_the_string();
$c = $b;
$c .= 'a';
$d = &$b;
The output was
- => 56904 - 63112 a => 133028 - 141276 b => 208420 - 216716 c => 208492 - 216716 c => 283816 - 283840 d => 283888 - 283888
The change between the two “c’s” is a core point.
Last update: 2008-02-01
0 Responses to “General belief about memory_get_usage”
Leave a Reply