Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exhaust of memory when creating large cache #52

Closed
xpasi opened this issue Oct 25, 2022 · 5 comments
Closed

Exhaust of memory when creating large cache #52

xpasi opened this issue Oct 25, 2022 · 5 comments
Labels
bug Something isn't working fix provided Code change provided for the issue
Milestone

Comments

@xpasi
Copy link

xpasi commented Oct 25, 2022

Having 14305 products will freeze zencart (or exhaust allocated memory on server) on language switch to newly installed language when usu starts creating cache for the names.

In this case includes/classes/usu.php, Line: 1155

Calls zen_get_products_name() 14305 times in a loop, which generates 14305 queries to database.

@lat9 lat9 added the bug Something isn't working label Oct 25, 2022
@lat9
Copy link
Owner

lat9 commented Oct 25, 2022

Thanks for the report! I'll be getting to the USU issues in a couple of weeks and will be looking to you to help me validate my solution.

@lat9 lat9 added this to the v3.1.0 milestone Jan 16, 2023
@lat9
Copy link
Owner

lat9 commented Jan 16, 2023

FWIW, I've reviewed the current handling of the caching and am of the opinion that it's hurting performance (and potentially memory consumption) more than it's helping.

For v3.1.0 and later the caching will be automatic and on a per-page basis. That will help performance in the determination of any category, product, manufacturer and ez-page names that are used in multiple spots on a specific page.

@lat9
Copy link
Owner

lat9 commented Jan 16, 2023

From the, albeit on teeny sites, profiling that I've done, using a per-page cache to not re-determine the various names seems to have a similar performance to the current 'mass' calculation ... without the possible out-of-memory conditions that the current implementation raises.

@lat9 lat9 added the fix provided Code change provided for the issue label Jan 30, 2023
lat9 added a commit that referenced this issue Jan 31, 2023
- Casting `$cID` to an int at this point 'kills' sub-category URL generation, dropping any `_nnn` additions.  The processing further down in the `parse_parameters` method casts the category id to an int when grabbing the category's name.
- Removing the (now now present) `USU_CACHE_GLOBAL` use.
@lat9 lat9 closed this as completed Feb 3, 2023
@xpasi
Copy link
Author

xpasi commented Mar 17, 2023

I finally had the time to install this on the customers site, and can verify that it now works with a large product database.

@lat9
Copy link
Owner

lat9 commented Mar 17, 2023

Thanks for taking the time to let me know that the update did, in fact, correct your issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fix provided Code change provided for the issue
Projects
None yet
Development

No branches or pull requests

2 participants