How to destroy an object?

后端 未结 6 1116
挽巷
挽巷 2020-11-29 01:54

As far as I know (which is very little) , there are two ways, given:

$var = new object()

Then:

// Method 1: Set to null
$va         


        
6条回答
  •  南笙
    南笙 (楼主)
    2020-11-29 02:57

    I would go with unset because it might give the garbage collector a better hint so that the memory can be available again sooner. Be careful that any things the object points to either have other references or get unset first or you really will have to wait on the garbage collector since there would then be no handles to them.

提交回复
热议问题