Closed javorszky closed 5 years ago
It looks like the get_post_metadata
filter contents are never garbage collected properly. Even with 8G of memory it dies.
It just randomly fixed itself. The last moment when I still reproduced the problem was a call to wc_get_product( $id )
in the backwards compatibility class get attributes method.
Same here when trying to migrate the data executing the following command:
wp wc-product-tables migrate-data --clean-old-data
This is what is printed on the terminal:
mmap() failed: [12] Cannot allocate memory
PHP Fatal error: Out of memory (allocated 226492416) (tried to allocate 20480 bytes) in /vagrant/www/nac/public_html/wp-content/plugins/woocommerce-product-tables-feature-plugin-1.0-beta-1/includes/class-wc-product-tables-backwards-compatibility.php on line 1488`
Increasing memory_limit in php.ini from 128M to 512M allowed me to finish the migration of a site with 20K products.
I couldn't reproduce both errors, but I definitely agree that WordPress shouldn't be using more than a few dozen megabytes under normal circumstances. If it is this plugin that is causing this problem we need to investigate.
We need to know what part of the script is consuming too much memory as the PHP error only shows the point where the script died due to memory exhaustion which is not necessarily the same. The only way I know to investigate PHP memory usage is analyzing Xdebug execution trace files generated with xdebug.show_mem_delta enabled (https://xdebug.org/docs/execution_trace). Could you please try it and share your findings? I'm open to other suggestions on how to further investigate this as analyzing Xdebug execution trace files is a manual and time-consuming process.
It looks like the get_post_metadata filter contents are never garbage collected properly.
@javorszky, could you please elaborate on how you came to the conclusion that this is happening and that is what is causing the memory exhaustion error?
@javorszky Are you using Product Bundles by chance? I've seen a similar behavior when migrating data with product types of Bundle.
I don't remember. It was a year ago, and I'm sorry I wasn't around to expand on this. I doubt I can reproduce it and I don't have time to attempt again. Because of this, I'm closing this issue. Feel free to reopen it if you still encounter it.
Set memory limit to 4 Gb on my test site to test whether it's my system, or the plugin. It's the plugin.
A tiny site with a grand total of 34 products, and sub-100 orders / subscriptions should probably not die with 4 Gb of memory. The entire database itself is 6.1 MB in size, so unless the plugin generates an infinite number of variables / nesting, 4 Gb memory should be laughable.