This is a migrated thread and some comments may be shown as answers.

How to release memory

1 Answer 116 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Victor
Top achievements
Rank 1
Victor asked on 25 Jun 2013, 09:09 PM
Hello,
I'm trying to use RichTextBox to browse docx files from local file system in out of browser application. Performance of the control is good, but memory footprint observed through the Task Manager keeps growing if I keep opening the same set of files repeatedly. Telerik binaries are Q2 2013. RichTextBox is used in read-only mode.

Is there any way to avoid this issue or "reset" existing control to free memory?

Thanks,
Victor

XAML:

<Grid Background="White" >
                   
                    <Grid.RowDefinitions>
                        <RowDefinition Height="21"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>
                    
                    <StackPanel Name="SubMenu" Orientation="Horizontal" Background="LightGray">
                        <TextBlock Text="{Binding SelectedDocumentName}" HorizontalAlignment="Center"/>

                    </StackPanel>

                    <telerik:RadRichTextBox x:Name="RadRichTextBox" Grid.Row="2" IsReadOnly="True"
                                            VerticalScrollBarVisibility="Hidden"/>

                </Grid>

In code behind:

        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            IReferenceDocumentsViewModel vm = KernelManager.KernelInstance.Get<IReferenceDocumentsViewModel>();
            DataContext = vm;
            ((INotifyPropertyChanged)vm).PropertyChanged += new PropertyChangedEventHandler(LoadDocument);
         }

        void LoadDocument(object source, PropertyChangedEventArgs args)
        {

            if (args.PropertyName.CompareTo("SelectedFile") == 0)
            {
                using (Stream stream = File.OpenRead(((IReferenceDocumentsViewModel)DataContext).SelectedFile))
                {
                    RadDocument document = null;
                    IDocumentFormatProvider provider = new DocxFormatProvider();
                    document = provider.Import(stream);
                    RadRichTextBox.Document = document;
                }
            }
        }

1 Answer, 1 is accepted

Sort by
0
Boby
Telerik team
answered on 28 Jun 2013, 06:37 AM
Hi Victor,
Memory leaks are sometimes reproducible only in specific scenarios. Could you open a support ticket and send us simple application that reproduces it? Also note that garbage collection is invoked only when needed, so increasing the memory counters in Task Manager is not always sign of a problem. You can manually induce full garbage collection with the following method sequence:
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();


Regards,
Boby
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
RichTextBox
Asked by
Victor
Top achievements
Rank 1
Answers by
Boby
Telerik team
Share this question
or