PHP Garbage Collection

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. ?>

Laeeq

A web developer who has a love for creativity and enjoys experimenting with various techniques in both web design and development. If you would like to be kept up to date with our posts, you can follow us on Twitter, or even by subscribing to our RSS Feed.

Leave a Reply

Your email address will not be published. Required fields are marked *

WordPress SEO fine-tune by Meta SEO Pack from Poradnik Webmastera