Is there garbage collection in PHP?

I know that in PHP you do not need to free memory. Is the garbage collector reached?

+49
garbage-collection memory-management php
Nov 14 '09 at 20:28
source share
5 answers

Yes, there is [here] a good article describing its pitfalls. In PHP> 5.3.0 there is also a gc_enable function.

+48
Nov 14 '09 at 20:31
source share

PHP has a combination of garbage collection and reference counting. The latter is the main way to manage memory, while the garbage collector collects pieces that the reference count (circular links) skips. Prior to 5.3, php only had ref-counting, and even in 5.3 it still saves memory.

+5
Nov 14 '09 at 22:49
source share

Yes. There is also session cleanup performed by the garbage collector.

+3
Nov 14 '09 at 20:30
source share

since 5.3.0 there is support for garbage collection. please check out this very informative article at php.net http://php.net/manual/en/features.gc.php

+2
Feb 05 '13 at 12:30
source share

Starting with 5.3.0, you can force garbage collection using the gc_collect_cycles function .

+1
Apr 6 2018-10-06T00:
source share



All Articles