Skip to main content

All Questions

Tagged with
8 votes
1 answer
1k views

PHP Generators - Garbage Collection

Simple question. When or how, by PHP or yourself do generators destroy their stacks? Take the following example: function doWork(): Generator { // create some objects. $o1 = new stdClass(); ...
Flosculus's user avatar
  • 6,918
2 votes
3 answers
467 views

Capturing (externally) the memory consumption of a given Callback

The Problem Lets say I have this function: function hog($i = 1) // uses $i * 0.5 MiB, returns $i * 0.25 MiB { $s = str_repeat('a', $i * 1024 * 512); return substr($s, $i * 1024 * 256); } I would ...
Alix Axel's user avatar
  • 154k
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