Whenever I've received this error, I just increased the memory to fix it. I have a case where, for testing purposes, I want to cause a page to use up all the memory however big I set the memory_limit.
I have no idea how to go about doing that.
EDIT: I tried this:
<?php
echo "start";
@ini_set('memory_limit', '1M');
$test = "a";
while (1) {
$test = "a" + $test;
}
echo "done";
?>
But it didn't crash. At the end it just printed "startstart" which is strange that it was printed twice...
I'd like a simple code example, the "put a lot of stuff in memory".. well I know that much.
Should eat all memory.
$a = 'x';
while (true) {
$a = $a.$a;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With