U4-8430 - Better memory management for XML cache when persisting the file

Created by Shannon Deminick 10 May 2016, 11:14:48 Updated by Stephan 19 May 2016, 15:03:40

Relates to: U4-8476

This fixes the LoadContentFromDatabase method - before this was storing every single xml node in memory in dictionaries (x2) and then performing the re-organization of all nodes afterwords to construct a document, now we just read each row and organize the document accordingly,


Shannon Deminick 10 May 2016, 11:15:10


Shannon Deminick 17 May 2016, 11:28:27

This issue is also part of this PR: http://issues.umbraco.org/issue/U4-8461

Stephan 17 May 2016, 17:32:03

The thing about reading the xml and building the document without using many dictionaries seems to make sense.

The thing about caching the cloned xml... worries me. When the SafeXmlReaderWriter is disposed, it assigns the cloned xml back to content._xml... so in a way the cloned xml becomes "publish" and should ''not'' be modified anymore. Whereas with what you are doing... any further change will impact that content._xml value which therefore is not immutable anymore. That is, it is now accessed by other requests.

So... if in, say, a controller, I publish three content items, the first one will cause a clone to be created and assigned to _xml ''and become visible by other requests and yet be modified when publishing the second item'' which (I think) is what the whole cloning was supposed to prevent?

Shannon Deminick 17 May 2016, 19:37:11

Hrm ok, let's chat about this tomorrow - was hoping there was a way to prevent the re-cloning during a specific sequence of events since that will kill memory usage with a large cache. Not sure there's an easy way to do that though due to the way things work with the xml cache.

Shannon Deminick 19 May 2016, 14:15:25

I've reverted that cloning part now, will create a diff issue for that.

Stephan 19 May 2016, 15:03:35


Priority: Normal

Type: Bug

State: Fixed


Difficulty: Normal


Backwards Compatible: True

Fix Submitted:

Affected versions:

Due in version: 7.5.0

Sprint: Sprint 15

Story Points: