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 to Remove Leading & Trailing White Spaces with PHP
  • Parse HTML/Web Pages with PHP
  • Block Multiple IP Addresses Using PHP
  • How much memory do PHP variables use?
  • Manipulating PHP arrays: push, pop, shift, unshift


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