Completed
Last Updated: 26 Oct 2018 11:32 by ADMIN
Rick
Created on: 04 Sep 2018 20:48
Category: RichTextBox
Type: Bug Report
2
RichTextBox: Memory leak in CreateDeepCopy with lists
Add the following code to an application with a RadRichTextBox in it:

for (var i = 0; i < 1000; i++)
{
    var doc = radRichTextBox.Document.CreateDeepCopy();
}

If your document does not contain any lists it behaves as expected: memory usage increases until the next GC when it is collected. If there are lists in your document the RadDocument instances created by CreateDeepCopy are never collected and your app will run out of memory.

Fix available in LIB Version 2018.3.1029.
4 comments
ADMIN
Boby
Posted on: 26 Oct 2018 05:57
Thank you for the additional information Rick! We believe that we've isolated the issue and currently a possible fix is in testing. The reason for the identified leak was that the original document holds references to the cloned ones. We will post any status updates here.
Rick
Posted on: 25 Oct 2018 19:01
We support docx and rtf created in word, html which we parse with a custom HTML parser, and documents created directly in the editor. I have been able to reproduce this with documents created in all 4 scenarios and have attached them.
ADMIN
Boby
Posted on: 23 Oct 2018 15:35
Could you also specify how are you creating the document with the list? By import, or by code? If possible, could you share the document and/or the source code for the creation? If more appropriate, you can attach the sample document in a support ticket.
ADMIN
Boby
Posted on: 23 Oct 2018 15:22
Hello Rick, and thank you for reporting this. It seems that this is a memory leak related to the static list styles contained in DocumentDefaultStyles. We can propose the following workaround:
- after using the cloned instance of RadDocument ("doc" in the case of the sample code), reset the list styles. The code is unusual as it does kind of "forbidded" operation, but it will detach the references between the document lists and the static list style instances:

foreach (var documentList in ((RadDocument)doc).ListManager.GetAllDocumentLists())
{
	try
	{
		documentList.Style = null;
	}
	catch (ArgumentNullException)
	{
	}
}

Please let us know if the workaround works for you. You can also open a support ticket if you need further assistance.