Viewing PDF Files in RadBook Performance issue

2 posts, 0 answers
  1. Vahid
    Vahid avatar
    5 posts
    Member since:
    Sep 2007

    Posted 07 Apr 2015 Link to this post


    I'm using RadBook and Pdf viewer as follow:

     Xaml Code:

        <DataTemplate x:Key="LeftPageTemplate">
                    <UI:FixedDocumentSinglePagePresenter Page="{Binding}"  Width="325" Height="447" FlowDirection="LeftToRight"/>
                    <hosts:DrawingCanvas  Width="325" Height="447" Margin="15" Background="#00000000" FlowDirection="LeftToRight" />
    <telerik:RadBusyIndicator x:Name="BusyIndicator">
        <telerik:RadBook x:Name="book"
                     LeftPageTemplate="{StaticResource LeftPageTemplate}"
                     RightPageTemplate="{StaticResource LeftPageTemplate}"
                      BorderBrush="{telerik:Windows8Resource ResourceKey=BasicBrush}"/>

    C# Code:

    public void LoadFile(Stream stream)
        BusyIndicator.IsBusy = true;
        var UISyncContext = TaskScheduler.FromCurrentSynchronizationContext();
        var task = new Task<RadFixedDocument>(() => LoadPdf(stream));
        task.ContinueWith(t =>
            book.ItemsSource = t.Result.Pages;
            TotalPages = t.Result.Pages.Count;
            BusyIndicator.IsBusy = false;
        }, UISyncContext);
    private RadFixedDocument LoadPdf(Stream stream)
        return new PdfFormatProvider(stream, FormatProviderSettings.ReadOnDemand).Import();

    Everything seems to work fine!

    But the problem is when I Load a file and start browsing pages, and monitor it on Task Manager, memory grows too high (i.e. more than 2GB)

    Look at the attached files, one from Task manager and one from ANTS Memory Profiler!

     What's wrong with my code? Should I do some extra work like releasing objects, pages, ... any thing!?

  2. Peshito
    Peshito avatar
    585 posts

    Posted 10 Apr 2015 Link to this post


    Thank you for your question.

    I tried to reproduce your issue but to no avail. Attached is the project I worked on using the code snippet you have provided. Please modify it so the issue becomes reproducible or simply attach a runnable copy of yours.

    Note that this is a forum thread and you should to use a third party web site for files sharing in order to share the sample.


    See What's Next in App Development. Register for TelerikNEXT.

Back to Top