Problem/Motivation
When a taxonomy vocabulary contains too much terms, it is absolutely impossible to reach some pages like taxonomy overview, even if their content is paginated, because of an huge memory usage. This is caused by the taxonomy_get_tree function for huge taxonomies, but for medium sized taxonomies, this is also caused by the fact that we never clean unused variables.
For information, with a 72000 terms taxonomy (what is not so many for big websites) :
$start = memory_get_usage(TRUE);
$tree = \Drupal::entityManager()->getStorage('taxonomy_term')->loadTree($vid); // 72000 terms
$used_memory = memory_get_usage(TRUE) - $start;
echo $used_memory; // ~ 242 MB
Proposed resolution
Just unset loadTree result when it is not needed anymore. This will not save the life of huge websites but this will definetely help medium ones to stay usables.
Remaining tasks
Post the patch
User interface changes
None
API changes
None
Beta phase evaluation
Issue category | Bug because it can cause fatal errors on very common features |
---|---|
Issue priority | Major because that's a bug |
Prioritized changes | The main goal of this issue is performance. (By clearing that unused variables we can free up a lot of memory) |
Disruption | Not disruptive for core, contributed and custom modules because the variables are cleared while neither the core or a hook uses them. |