PHP anonymous function 设置为 static 优化内存回收

PHP anonymous function 会被创建为 Closure 对象实例,默认情况下,会把所在对象的 $this 保持在 Closure 对象实例中。
如果$this没有被使用,而 Closure 的生命周期比 $this 更长,造成了 $this 对象无法被回收。如果关联的实例过多,造成内存占用变高,内存关联开销变大,速度变慢。

你可能感兴趣的:(PHP anonymous function 设置为 static 优化内存回收)