Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

DynamicDataStore.InternalLoad copies dictionary every time

Fixed in

EPiServer.CMS.Core 11.18.0

(Or a related package)

Created

Apr 16, 2020

Updated

Aug 11, 2020

Area

CMS Core

State

Closed, Fixed and tested


Description

protected internal virtual object InternalLoad(Identity id, Type type, LoadAsObjectType loadAs, ProviderCallContext parentContext)
        {           
            //First check if object is already loaded in the context of this store instance
            object obj;
            if (_identitiesToObjectsMap.TryGetValue(id, out obj))
            {
                return GetObjectInRequiredFormat(loadAs, obj, type);
            }
 
            //Check if object is present in "shared" cache
            ObjectContext cachedObject = CacheProvider.Instance.GetInternal(id.ExternalId.ToString(), type, 
                new LoadingContext() {* CurrentObjects = new Dictionary<Identity, object>(_identitiesToObjectsMap)});*

If the collection is big enough, every time an item is loaded, DDS will create a copy of the dictionary. This is not only slow and wasteful, but also can cause frequent Gen 2 GC

Note for QA: This could be verified that Form postings and reading of form postings work as expected