Is it possible to clear all resources in PHP?
I know that you can get all defined functions with get_defined_vars
with unset you can easily clear these resources.
But that’s not enough for me. I have a script that runs a long time (~1h 30m) to execute many functions.. but while the executions the script collected informations that don’t matter anymore.. the script exports products and get around 0.2MB – 0.5MB for each product (3200 products)
That is more than 600mb of memory usage. I optimized the script as good as I can, but I don’t get it smaller.
I is possible to get all included files with get_included_files or get_declared_classes; is it possible to clear these infos? Remove the classes (except some required like autoloader classes) or other included files so that I can free more RAM?
Or do you know other ways to optimize the server usage while execution?
Maybe it’s a stupid question, but I would be happy for each hint to improve the performance of the PHP script.
Info of the script environment: the script runs on an old Magento version 1.4 that has huge problems with the cache and performance; an update to a newer version is at the moment not possible.
We had a script that consumed up to 2GB of memory, and leaked memory like crazy (it uses Doctrine 1.1).
After
unset()ingas much as we could, we then addedgc_enable()to the top of the script, andgc_collect_cycles()in strategic locations.This did help with reclaiming some of the used memory, but did slow the script down by a small amount.