Is this a php memory leak?

Posted by mseifert on Stack Overflow See other posts from Stack Overflow or by mseifert
Published on 2013-10-31T21:08:00Z Indexed on 2013/10/31 21:55 UTC
Read the original article Hit count: 111

Filed under:
|

I have memory_get_usage() in the footer of my page and with each refresh of the page, I watch it increase by about 100k each time. My page load creates many objects and destroys them when done . My parent objects each have __destruct() which uses unset() with all child objects. Child objects with a reference back to the parent, have __destruct() to unset() these references.

Inserting memory_get_usage() before and after processing different parts of my page only tells me how much of the total usage was added due to that part of the script. How do I go about determining what memory is lost and not recycled for garbage collection after the page finishes loading?

I have one global $_SESSION var containing objects storing user info, but have verified using strlen(serialize($object)) that this object is not growing in size.

I presume that what I am seeing is a memory leak and that php garbage collection should be in effect after the script ends. Any ideas how to debug this?

© Stack Overflow or respective owner

Related posts about php

Related posts about memory-leaks