CodeIgniter Forums
Free the space - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Free the space (/showthread.php?tid=25737)



Free the space - El Forum - 12-22-2009

[eluser]briandkid[/eluser]
Good Evening,

What is the code to free the memory of the RAM

Thanks.


Free the space - El Forum - 12-22-2009

[eluser]BrianDHall[/eluser]
If you unset() all references to a variable it will be freed, and PHP and it's garbage collector will (at its discretion) release memory. Or it will do it at the end of the script execution.

http://www.php.net/manual/en/function.gc-collect-cycles.php

gc_collect_cycles() was made available in PHP 5.3 to force the gargabe collector to do its magic, but there are few good reasons to do this. If you are running out of memory PHP will call its GC on it's own - so just use unset() in certain situations where memory usage becomes a problem.