# [PATCH] Bug #60139 closure memory leaks

- Thread: https://externals.io/message/55988
- Original archive: https://news-web.php.net/php.internals/55988
- Started by Arnaud Le Blanc on 2011-10-29T11:44:27+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #55988 — Arnaud Le Blanc — 2011-10-29T11:44:27+00:00

URL: https://externals.io/message/55988#55988

Hi,

Closures can hold references to variables, but don't expose them to the 
garbage collector. The GC is unable to find cycles in which a closure is 
involved, and this can create memory leaks.

I've reported this problem in https://bugs.php.net/bug.php?id=60139 and posted 
a patch. Can someone please review it ? This fixes the problem by returning 
the closure's closed variables and this_ptr from get_properties (most of this 
has been copied from SplObjectStorage's get_properties). I would like to 
commit in 5.3 as well.

Best Regards,
