Search code examples
phpcollectionsmemory-leaksglobalgarbage

PHP: When does a global variable get removed from memory


My intention is to know that if a global variable can cause memory leaks. In my script I am declaring a resource as global variable. I kind of know that it should get destructed when the script ends. But is there a way a global variable can cause memory leak and affect the HTTP server (say Apache) in the long run of application (if I do not unset my variable from $GLOBALS ) ?

Thanks, Aravind


Solution

  • Global vars in PHP die when the script ends. Very short life ;)