Possible Memory Leak in C1PdfViewer

Posted by: tobias.heilmannseder on 7 September 2018, 12:45 am EST

    • Post Options:
    • Link

    Posted 7 September 2018, 12:45 am EST

    When I make a really small Wpf Application with only one C1PdfViewer Control it is using huge amounts of memory when I scroll pages.

    See attached solution.

  • Posted 7 September 2018, 12:47 am EST

    <Window
        x:Class="PdfViewerMemoryLeak.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:c1="http://schemas.componentone.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:local="clr-namespace:PdfViewerMemoryLeak"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        Title="MainWindow"
        Width="800"
        Height="450"
        mc:Ignorable="d">
        <Grid>
            <c1:C1PdfViewer
                x:Name="C1PdfViewer"
                Focusable="True"
                Loaded="PdfHelpViewer_OnLoaded"
                OpenButtonVisibility="Visible"
                ToolbarVisibility="Visible"
                Visibility="Visible" />
        </Grid>
    </Window>
    
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Navigation;
    using System.Windows.Shapes;
    using C1.WPF.PdfViewer;
    
    namespace PdfViewerMemoryLeak
    {
        /// <summary>
        /// Interaction logic for MainWindow.xaml
        /// </summary>
        public partial class MainWindow : Window
        {
            public MainWindow()
            {
                InitializeComponent();
            }
    
            private void PdfHelpViewer_OnLoaded(object sender, RoutedEventArgs e)
            {
                if (sender is C1PdfViewer c1PdfViewer && c1PdfViewer.IsVisible)
                {
                    c1PdfViewer.ViewMode = ViewMode.FitWidth;
                    c1PdfViewer.LoadDocument(@"..\..\made-with-cc.pdf");
                }
            }
        }
    }
    
    
  • Posted 9 September 2018, 3:45 pm EST - Updated 4 October 2022, 12:14 am EST

    Hello,

    Thank you for sharing the code snippets. I am able to reproduce the issue at my end.

    Could you please try loading your PDF using the C1FlexView/C1PdfDocumentSource controls. For this, I would suggest to use the product sample installed at \Documents\ComponentOne Samples\WPF\C1.WPF.Document\CS\PdfView location and verify the behavior at your end.

    I would also suggest you to move your application to use C1PdfDocumentSource which should work fine. Please refer attached video.

    Thanks,

    Ruchir

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels