How to release memory

2 posts, 0 answers
  1. Victor
    Victor avatar
    2 posts
    Member since:
    Jan 2011

    Posted 25 Jun 2013 Link to this post

    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;
                    }
                }
            }
  2. Boby
    Admin
    Boby avatar
    595 posts

    Posted 28 Jun 2013 Link to this post

    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 >>
  3. DevCraft banner
Back to Top