Repository › Forums › Support › WooCommerce Extended Coupon Features PRO › Memory Leaks
- This topic has 34 replies, 2 voices, and was last updated 4 years, 11 months ago by Soft79.
-
AuthorPosts
-
April 11, 2018 at 7:28 am #2969Jonathan MooreParticipant
probably, the cart is instantiated by the abandoned shopping carts which is checking in the background to see if it should send an email reminder: at this point there is no user request and no order language set, so polylang can’t detect language.
On the other hand, there is no user to choose free products, and the free product selection doesn’t appear and isn’t needed in the shopping cart reminder email, so could we ensure that the free products selection is not even called if there is no request context?
I’ll look at this some more..
April 11, 2018 at 8:49 am #2970Soft79KeymasterI see a potential infinite recursion in registerCouponStringsForTranslation of the Polylang Integration plugin.
That function is called when filter woocommerce_coupon_get__wjecf_* is fired, but may fire the same filter again because it loads coupon meta fields.
April 11, 2018 at 8:54 am #2971Soft79KeymasterTry moving the
$coupons_loaded = true;
to the top of the function.April 11, 2018 at 11:43 am #2978Jonathan MooreParticipantoddly, that change alone seemed to make things much worse…
April 11, 2018 at 11:45 am #2979Soft79KeymasterYou did place it after
if (! $coupons_loaded) {
?April 11, 2018 at 11:52 am #2981Jonathan MooreParticipanthaha yes,
I’m just going to try disabling the whole module if we’re in cron.I’m suspecting the term translations as I know Polylang did some “optimisation” on that in recent versions: where the coupon is linked to product category it’s also trying to get the category translations..
April 11, 2018 at 11:55 am #2982Soft79KeymasterThe method used in registerCouponStringsForTranslation is a performance killer for sites with many coupons. I advise you to optimize this code.
April 11, 2018 at 11:58 am #2983Jonathan MooreParticipantyes, I just added a transient for the coupons..
April 11, 2018 at 7:18 pm #2984Jonathan MooreParticipantthis is a decoy, it’s also blowing up with the coupon translation module turned off, but the abandoned cart and autocoupons turned on.
April 11, 2018 at 7:21 pm #2985Soft79KeymasterYour best bet would be debugging this in a testing environment. Preferably with Xdebug and/or disabling all plugins except WC and our plugin.
April 11, 2018 at 7:29 pm #2986Jonathan MooreParticipantI know what you mean – and I will – but this doesn’t happen in a test environment, or interactively
and the test environment isn’t trying to email clients about abandoned shopping carts etc etc.April 11, 2018 at 9:32 pm #2989Soft79KeymasterAnother trick would be placing
error_log(print_r(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 100), true));
right before the lines that produce memory errors. For example if memory usage is high, like soif (memory_get_usage() > 100000000)
.Make sure you do this only once per location per request, to prevent flooding the log.
April 11, 2018 at 9:52 pm #2990Jonathan MooreParticipantif I knew what are the lines that really produce the memory errors that could be doable.
At lot of the time it is just like:
[11-Apr-2018 18:41:45 UTC] PHP Fatal error: Allowed memory size of 201326592 bytes exhausted (tried to allocate 20480 bytes) in /wp-includes/plugin.php on line 449In these cases the failure to allocate 20480 bytes is a symptom of something having eaten all the memory, not the cause.
It all stops though when WJECF_AutoCoupon is disabled.
April 11, 2018 at 10:02 pm #2991Soft79KeymasterPlace it before line 449 of that file and check the debug trace.
April 11, 2018 at 11:11 pm #2992Jonathan MooreParticipantsure, added one..
I’ve just rewritten the coupon translation to use WC_Coupon everywhere (and so woocommerce’s caching) and avoid loading any posts or use any posts api, I’ll just make sure that’s fine and leave WJECF_AutoCoupon turned off till I have time to debug it further. -
AuthorPosts
- You must be logged in to reply to this topic.