Restrict the number of nodes held in the node_load() static cache

Created on 17 February 2009, over 16 years ago
Updated 6 August 2025, 7 days ago

Under normal circimstances caching every node into the static cache is ok because usually at a guess only 10-20 nodes would be loaded on every page request.

However when doing conversions or in situations when a lot of nodes needs to be loaded at one time this can cause a WSOD because of memory issues.

With the #233091: Move code from update.php into includes/update.inc β†’ patch which will allow upgrades to be done from the shell instead of via the browser which can take much longer it is quite possible to load all of the nodes in a system into memory.

This change implements a basic less used removed first purging policy to drop nodes which are just taking up memory and not to be used. Under normal situations this should not be done, but in extreme use cases to will keep the memory useage by the node_load() at a reasonable level.

I am not sure if 20 is a good or bad number, but for testing the purging it was much better to have a lower number to test. I have a couple of drupal_set_messages() which need to be removed, but this to see how often the cache is being purged as it should not be done too much.

✨ Feature request
Status

Needs work

Version

11.0 πŸ”₯

Component

entity system

Created by

πŸ‡¦πŸ‡ΊAustralia gordon Melbourne

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024