Unplanned
Last Updated: 18 Sep 2023 17:38 by Martin Ivanov
Martin Ivanov
Created on: 18 Sep 2023 17:38
Category: PDFViewer
Type: Bug Report
2
PdfViewer: Memory leak when using RadPdfViewerNavigationPane and changing the DocumentSource of RadPdfViewer at runtime

A memory leak occurs in the RadTreeView control used for the table of contents in the RadPdfViewerNavigationPane, when changing the DocumentSource of RadPdfViewer at runtime.

To work this around, you can get the RadTreeView used by RadPdfViewerNavigationPane and manually clear its internal item storage before assigning the new DocumentSource.

 

private void ReloadDocument()
{
	var navigationPane = this.pdfViewerNavigationPane;
	var navigationPaneTreeView = navigationPane.FindChildByType<RadTreeView>();
	if (navigationPaneTreeView != null)
	{
		object itemStorage = typeof(RadTreeView)
			.GetProperty("ItemStorage", BindingFlags.Instance | BindingFlags.NonPublic)
			.GetValue(navigationPaneTreeView);
		MethodInfo itemStorageClearMethod = itemStorage.GetType().GetMethod("Clear", BindingFlags.Instance | BindingFlags.NonPublic);
		itemStorageClearMethod.Invoke(itemStorage, null);		
	}
	
	this.DocumentSource = theNewDocumentSource;
}

 

0 comments