More Related Content Similar to PHPConPl 2013 - Allowed memory size of X bytes exhausted Similar to PHPConPl 2013 - Allowed memory size of X bytes exhausted (20) More from Piotr Pasich (9) PHPConPl 2013 - Allowed memory size of X bytes exhausted19. public function foo($file1, $file2){
$obj = new Obj();
$data = array();
$data[] = $obj->importAFile($file1);
$data[] = $obj->importAFile($file2);
return $data;
}
23. public function foo($file1, $file2){
$obj = new Obj();
$data = array();
$data[] = $obj->importAFile($file1);
$data[] = $obj->importAFile($file2);
return $data;
}
25. It frees all variables to which
there are no references left
61. typedef struct _zval_struct {
zvalue_value value;
/* variable value */
zend_uint refcount__gc; /* reference counter */
zend_uchar type;
/* value type */
zend_uchar is_ref__gc; /* reference flag */
} zval;
62. typedef union _zvalue_value {
long lval;
/* long value */
double dval;
/* double value */
struct {
char *val;
int len;
/* this will always be set for strings */
} str;
/* string (always has length) */
HashTable *ht;
/* an array */
zend_object_value obj; /* stores an object store handle,
and handlers */
} zvalue_value;
64. | 64 bit | 32 bit
--------------------------------------------------zval
| 24 bytes | 16 bytes
+ cyclic GC info
|
8 bytes | 4 bytes
+ allocation header
| 16 bytes | 8 bytes
===================================================
zval (value) total
| 48 bytes | 28 bytes
===================================================
bucket
| 72 bytes | 36 bytes
+ allocation header
| 16 bytes | 8 bytes
+ pointer
|
8 bytes | 4 bytes
===================================================
bucket (array element) total | 96 bytes | 48 bytes
===================================================
total total
| 144 bytes | 76 bytes
68. 2^17 = 131 072
131 072 – 100 000 = 31 072 pointers
83. Fatal error: Allowed memory size of
33554432 bytes exhausted (tried
to allocate 2798048 bytes) in
/***/app/http.php on line 6331
96. Default
0.0004 114272 -> str_split() ../trace.php:8
0.0153 117424 -> ret_ord() ../trace.php:10
1
0.0004
0.0007
114272
117424
-> str_split(string(6)) ../trace.php:8
-> ret_ord(string(1)) ../trace.php:10
3
0.0004
0.0007
114272
117424
-> str_split('Xdebug') ../trace.php:8
-> ret_ord('X') ../trace.php:10
4
0.0004
0.0007
114272
117424
-> str_split('Xdebug') ../trace.php:8
-> ret_ord($c = 'X') ../trace.php:10