1 | <?php |
---|
2 | /* |
---|
3 | Plugin Name: A plugin that uses a lot of memory while loading |
---|
4 | Plugin URI: http://localhost/ |
---|
5 | Description: Uses a lot of memory while the plugin loads |
---|
6 | Author: mattr |
---|
7 | Version: 1.0 |
---|
8 | */ |
---|
9 | |
---|
10 | define('WASTE_MEMORY_MB', 119); |
---|
11 | //define('WASTE_MEMORY_MB', 55); |
---|
12 | |
---|
13 | |
---|
14 | function waste_memory() { |
---|
15 | error_log('Current memory usage: ' . memory_get_usage()); |
---|
16 | error_log(' Allocating memory: ' . WASTE_MEMORY_MB . 'MB'); |
---|
17 | |
---|
18 | // 8 bytes x 128 x 1024 = 1 MB, multiplied by the constant |
---|
19 | $_SERVER['wasted_memory'] = str_repeat('12345678', 128 * 1024 * WASTE_MEMORY_MB); |
---|
20 | |
---|
21 | error_log(' Memory after allocation: ' . memory_get_usage()); |
---|
22 | } |
---|
23 | |
---|
24 | // Use up some memory now, while loading plugins |
---|
25 | waste_memory(); |
---|