PHP Garbage Collection

December 4th, 2012 by Laeeq | No comments

PHP garbage collection is largely a reference counter. If you are keeping references which are still accessible around these will easily add up if not freed. PHP has built-in function to manage that garbage collection or memory cleanup for long-running scripts. these php functions can easily improve your site performance. Below is the php script for garbage collection that’s surely work for you.

  1. <?php
  2. gc_enable(); // Enable Garbage Collector
  3. var_dump(gc_enabled()); // true
  4. var_dump(gc_collect_cycles()); // # of elements cleaned up
  5. gc_disable(); // Disable Garbage Collector
  6. ?>

You can subscribe to PHPZAG.COM posts by Email

 

Related Topics:

  • How much memory do PHP variables use?
  • Manipulating PHP arrays: push, pop, shift, unshift
  • 10 Super Useful PHP Code Snippets
  • Let’s play with php.ini file Configuration
  • 15+ regular expressions for PHP developers
  •  

     

    1. No comments yet.
    1. No trackbacks yet.