Skip to main content

All Questions

-1 votes
2 answers
104 views

How (if possible) to optimize memory in this PHP example

I am trying to understand how PHP handles memory consumption in these two examples. Example: 1 // foo.php class foo{ public function __construct() { $a = new PDO(......
robue-a7119895's user avatar
22 votes
4 answers
4k views

How does PHP memory actually work

I've always heard and searched for new php 'good writing practice', for example: It's better (for performance) to check if array key exists than search in array, but also it seems better for memory ...
George G's user avatar
  • 7,639
3 votes
1 answer
4k views

Memory leak with malloc in php extension

I made a php extension which looks like: PHP_FUNCTION(function_name) { ... proc_data = ( char * )malloc(length); ... RETURN_STRINGL( proc_data, length, 1 ); } function_name is the ...
Tarun Chabarwal's user avatar
12 votes
1 answer
4k views

How does PHP assign and free memory for variables?

I was wondering when does PHP free the memory which is used for a variables for example function foo(){ $foo = 'data'; return $foo; // <- is the memory space for `$foo` emptied at this point?...
Alex's user avatar
  • 67.5k