DynamicDataStore.InternalLoad copies dictionary every time

Fixed in

EPiServer.CMS.Core 11.18.0


Apr 16, 2020


Aug 11, 2020


CMS Core


Closed, Fixed and tested


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