Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Display the current memory limit
- echo "Current memory limit: " . ini_get('memory_limit') . "\n";
- // Function to allocate memory
- function allocateMemory($sizeInMB) {
- $sizeInBytes = $sizeInMB * 1024 * 1024;
- $memory = str_repeat('a', $sizeInBytes);
- return $memory;
- }
- try {
- $allocatedMemory = [];
- $i = 1;
- while (true) {
- echo "Allocating {$i}MB of memory\n";
- $allocatedMemory[] = allocateMemory(1); // Allocate 1MB at a time
- $i++;
- }
- } catch (Exception $e) {
- echo "Caught exception: " . $e->getMessage() . "\n";
- } catch (Error $e) {
- echo "Caught error: " . $e->getMessage() . "\n";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment