AcclaroInc / craft-translations

Easily manage your Craft CMS website translations and drive global growth with simplified translation workflows.
https://plugins.craftcms.com/translations
Other
9 stars 11 forks source link

Memory Exhaustion Error When Selecting Multiple Entries for Translation #507

Open DieterVanhove opened 2 weeks ago

DieterVanhove commented 2 weeks ago

I am encountering a memory exhaustion error when using the plugin on the create order page. When selecting multiple entries for translation, the plugin seems to hit a memory limit, resulting in an Error 500.

Steps to Reproduce:

  1. Navigate to the new order page in the translations plugin.
  2. Select multiple entries for translation.
  3. On reload it throws an error 500.

If I select over a certain amount of entries, I receive an Error 500. The error log indicates a memory exhaustion problem.

Error log: PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 28672 bytes) in .../vendor/yiisoft/yii2/db/Command.php on line 1302

Environment:

Server Configuration:

Additional Information:

The server's memory limit is set to 512M, which is relatively high, yet the issue persists. Possible Cause: It appears that there might be a limit within the plugin or an inefficiency in handling multiple entries that leads to high memory usage.

MerrittBoydston commented 2 weeks ago

@DieterVanhove It appears that the issue you are experiencing is not a bug with the plugin, but rather a PHP memory limit exhaust error.

This can be resolved by increasing the memory limit in the php.ini file on your server. The amount of memory needed will continue to increase based on the usage of the app, as the more files there are, the more memory is required to process them.

To fix this issue, please refer to the below image for instructions on how to adjust the memory limit in the php.ini file:

IMG_1288

For more information on how to fix the PHP fatal error related to memory exhaustion, please refer to this resource: https://stackoverflow.com/questions/561066/fatal-error-allowed-memory-size-of-134217728-bytes-exhausted

If you have any further questions or need assistance, please feel free to reach out.

Thank you.

DieterVanhove commented 2 weeks ago

Hello @MerrittBoydston,

Our current PHP memory limit is already set to 512MB, which should be sufficient for most applications. Continuously increasing the memory limit is not a sustainable solution, as it only mitigates the symptom rather than addressing the root cause.

Given that this issue arises specifically when selecting multiple entries for translation, it suggests that the plugin may not be efficiently handling the process internally. I believe there might be an opportunity to optimize the memory usage within the plugin to better handle larger selections of entries.

Could you please investigate this further to identify potential inefficiencies in how the plugin processes multiple entries? This would ensure a more robust solution that benefits all users, rather than requiring continual increases in memory allocation.

Best regards.

MerrittBoydston commented 2 weeks ago

@DieterVanhove,

  1. How many entries are you attempting to translate in a single batch when seeing this memory error?
  2. What is the average size of the entries you are selecting for translation?
  3. Are there any patterns or specific types of entries that trigger this issue?

Thank you

DieterVanhove commented 2 weeks ago

Hi @MerrittBoydston,

  1. The number of entries I attempt to translate in a single batch varies. Sometimes it's around 10-15 entries, and other times it's more like 20-30 entries, depending on their size.
  2. Upon further testing, I believe the problem lies in the rendering of the Twig template. The logic in the actionOrderDetail function works fine until it tries to render the template. https://github.com/AcclaroInc/craft-translations/blob/b252b9aeba54a8811f3bea7883f335a75e4b68b5/src/controllers/OrderController.php#L86
  3. There are no specific patterns or types of entries that trigger this issue; it seems to be related to the quantity and size of the entries being processed.

Best regards,

DieterVanhove commented 1 week ago

Hi @MerrittBoydston,

I noticed that the "priority: high" tag has been removed. Could you please provide an estimated timeline for when this issue will be investigated and addressed?

Understanding the timeline will help us plan accordingly on our end.

Thank you.