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

Viewing PDF Files in RadBook Performance issue

1 Answer 99 Views
Book
This is a migrated thread and some comments may be shown as answers.
Vahid
Top achievements
Rank 1
Vahid asked on 07 Apr 2015, 02:30 PM

Hi

I'm using RadBook and Pdf viewer as follow:

 Xaml Code:

<UserControl.Resources>
    <DataTemplate x:Key="LeftPageTemplate">
        <Viewbox>
            <Grid>
                <UI:FixedDocumentSinglePagePresenter Page="{Binding}"  Width="325" Height="447" FlowDirection="LeftToRight"/>
                <hosts:DrawingCanvas  Width="325" Height="447" Margin="15" Background="#00000000" FlowDirection="LeftToRight" />
            </Grid>
        </Viewbox>
    </DataTemplate>
</UserControl.Resources>
 
<telerik:RadBusyIndicator x:Name="BusyIndicator">
    <telerik:RadBook x:Name="book"
                 LeftPageTemplate="{StaticResource LeftPageTemplate}"
                 RightPageTemplate="{StaticResource LeftPageTemplate}"
                 IsVirtualizing="True"
                 IsKeyboardNavigationEnabled="True"
                 HorizontalAlignment="Center"
                 VerticalAlignment="Center"
                 FirstPagePosition="Right"
                 HardPages="None"
                 Margin="10"
                 BorderThickness="1"
                  BorderBrush="{telerik:Windows8Resource ResourceKey=BasicBrush}"/>
</telerik:RadBusyIndicator>

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);
    task.Start();
}
 
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!?

1 Answer, 1 is accepted

Sort by
0
Peshito
Telerik team
answered on 10 Apr 2015, 08:22 AM
Hello,

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.

Regards,
Peshito
Telerik
 

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

 
Tags
Book
Asked by
Vahid
Top achievements
Rank 1
Answers by
Peshito
Telerik team
Share this question
or