gc_045.phpt 791 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. --TEST--
  2. GC 045: Total count persisted when GC is rerun due to destructor call
  3. --INI--
  4. zend.enable_gc=1
  5. --FILE--
  6. <?php
  7. class GlobalData
  8. {
  9. public static Bar $bar;
  10. }
  11. class Value
  12. {
  13. public function __destruct()
  14. {
  15. new Bar();
  16. }
  17. }
  18. class Bar
  19. {
  20. public function __construct()
  21. {
  22. GlobalData::$bar = $this;
  23. }
  24. }
  25. class Foo
  26. {
  27. public Foo $selfRef;
  28. public Value $val;
  29. public function __construct(Value $val)
  30. {
  31. $this->val = $val;
  32. $this->selfRef = $this;
  33. }
  34. }
  35. for ($j = 0; $j < 10; $j++) {
  36. for ($i = 0; $i < 3000; $i++) {
  37. new Foo(new Value());
  38. }
  39. }
  40. var_dump(gc_status());
  41. ?>
  42. --EXPECT--
  43. array(4) {
  44. ["runs"]=>
  45. int(10)
  46. ["collected"]=>
  47. int(25000)
  48. ["threshold"]=>
  49. int(10001)
  50. ["roots"]=>
  51. int(10000)
  52. }