zend_close_rsrc_list(&EG(regular_list));
} zend_end_try();
+#if ZEND_DEBUG
+ if (GC_G(gc_enabled) && !CG(unclean_shutdown)) {
+ gc_collect_cycles();
+ }
+#endif
+
zend_try {
zend_objects_store_free_object_storage(&EG(objects_store));
{
uint32_t i;
- /* Free object properties but don't free object their selves */
+ /* Free object contents, but don't free objects themselves */
for (i = objects->top - 1; i > 0 ; i--) {
zend_object *obj = objects->object_buckets[i];
}
}
- /* Now free objects theirselves */
+ /* Free objects themselves if they now have a refcount of 0, which means that
+ * they were previously part of a cycle. Everything else will report as a leak.
+ * Cycles are allowed because not all internal objects currently support GC. */
for (i = 1; i < objects->top ; i++) {
zend_object *obj = objects->object_buckets[i];
- if (IS_OBJ_VALID(obj)) {
+ if (IS_OBJ_VALID(obj) && GC_REFCOUNT(obj) == 0) {
/* Not adding to free list as we are shutting down anyway */
void *ptr = ((char*)obj) - obj->handlers->offset;
GC_REMOVE_FROM_BUFFER(obj);