Problem/Motivation
TypedDataManager creates property prototypes - e.g. a typed data instance of 'field_something' based on the entity/bundle/field name and static caches them. This is so that if multiple entities of the same type are loaded and the same fields are requested, it doesn't have to create the full typed data object every time.
However, this static cache also stores the parent typed data object within the prototype. When the parent is an entity object, this creates a static cache of entities that can never be cleared, making entity LRU caching ineffective. It will only include the entities for the first time a field is seen, but still not good.
Split from #3572625: Calling $entity->getTranslatedField() results in an entity-sized memory leak where I found several other issues with circular references and static caching in the typed data system but this is something that can be done self-contained.
Steps to reproduce
Proposed resolution
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
Issue fork drupal-3574198
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3574198-typeddatamanager-prototypes-should
changes, plain diff MR !14811
Comments
Comment #2
catchComment #4
smustgrave commentedSeems pretty straight forward. Only comment maybe when we say it's set later we say where? But that may just be me so not holding it up.
Comment #5
alexpottThis is a nice find and the solution looks clean - we need to create with the parent because
Committed and pushed b3c46ac0610 to main and ded7281b87e to 11.x and 3f19f9d3a4a to 11.3.x. Thanks!
Backported to 11.3.x as a low risk performance fix.