Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 294911

Memory leak - typed data prototypes for field items are not re-used like intended

$
0
0

Problem/Motivation

\Drupal\Core\Field\FieldTypePluginManager::createFieldItem() passes the $index of the field item as a $property_name which leads to the generation of a new prototype for every new field item of the same field. If there are 1000 items there will be 1000 prototypes. However the typed data manager uses a prototype cache for similar typed data objects and returns a cloned object from the prototypes whenever possible. Alternating by the $index just makes this prototype cache useless for field items and also introduces a memory leak the more items one initializes in a process, as they are never cleared by the garbage collector. This made our system of batch processing explode for a field with a lot of items and therefore I think this should be classified as a critical because of the memory leak.

Proposed resolution

Make the $property_name parameter of \Drupal\Core\TypedData\TypedDataManagerInterface::getPropertyInstance() optional and do not pass the field item index as property name anymore from \Drupal\Core\Field\FieldTypePluginManager::createFieldItem()

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet


Viewing all articles
Browse latest Browse all 294911

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>