Aspose.Slides Serializes Large Files Slowly

When I have a PPTX file of 400 Mb, Aspose.Slides takes many minutes to create the document object and serialise back to a file. Also, the machine memory quickly maxes out at 8 Gb and stays there for the entirety of processing. This is unusable as requests time out and the end user experience is horrible. How should PPTX of this size be processed? Version 21.9 of Slides used with the test code below. Happy to supply test PPTX file.

        string fileName;
        byte[] fileNameBytes;
        Stream ms;
        fileName = "D:\\Temp\\Latest Products Full.pptx";
        fileNameBytes = File.ReadAllBytes(fileName);
        ms = new MemoryStream(fileNameBytes);
        using (Aspose.Slides.Presentation pres = new Aspose.Slides.Presentation(ms))
            pres.Save(fileName.Replace(".pptx", "_out.pptx"), Aspose.Slides.Export.SaveFormat.Pptx);

@leigh.rowland,
Thank you for contacting support.

There were many updates after version 21.9. Please check your results using the latest version of Aspose.Slides if it is possible. If the issue persists, please share the following data:

  • a storage file link to the presentation file
  • OS version on which the code was run
  • .NET target platform in your app
  • your log data after profiling and diagnostics

@Andrey_Potapov
Thanks for your message. I have tried with Slides 22.3 and same issue. The code is tested using the framework v2 of the Aspose.Slides DLL. The code is complied with framework 4.5 and run on Win 10 i7 processor with 64 Gb memory. The download link for the file is:

https://nucleuscyber-my.sharepoint.com/:p:/g/personal/leigh_rowland_nucleuscyber_onmicrosoft_com/EQB2Zpzzm9FAj-1GNS8GKK4Bj0dj2Tpww-aNz2oE4SdS_g?e=plEhfX

Thanks for help

@leigh.rowland,
Unfortunately, I was unable to download the presentation file. Please use another file storage (Google Drive or Dropbox, for example).

If I understand correctly, you are using Aspose.Slides for .NET 2.0. Could you please confirm?

Yes, we are targetting .net 2.0 version of the Aspose.Slides (altough we have also tested against .net 3.5 & 4.0)

Can you try this download link. I have granted this full permission. If it does not work, can you share your email address so I can try a different method

https://nucleuscyber-my.sharepoint.com/:p:/g/personal/leigh_rowland_nucleuscyber_onmicrosoft_com/EQB2Zpzzm9FAj-1GNS8GKK4BMDZtNYJ9-2E66Vv5C53SXQ?e=Hx9ok2

@leigh.rowland,
Thank you for the presentation file. Please collect memory usage data for the test in the environment you described by taking two memory snapshots - before and after loading/saving the presentation, and share a screenshot with Memory Usage and CPU Usage information from your side. But first, please don’t copy the file data to memory as shown in your code example. You should use the code examle for the test like this:

using (Presentation pres = new Presentation("Latest Products Full.pptx"))
    pres.Save("Latest Products Full_out.pptx", SaveFormat.Pptx);

Also, please сalculate exactly how long it took to complete the test.

@Andrey_Potapov

Sorry for the delay in my response. attached are 2 memory snapshots. The first after the constructor and the second after the save. The constructor takes 35891 milliseconds and the save takes 133438 milliseconds. Also please note, the test will only execute it the executable is built for 64 bit - 32 bit compilation results in an “out of memory exception” before the constructor completes.

The speed of execution is essential and writing a file to disk and reading it back would make the process very slow. So we need to use memorystreams through our code. I have run a test as requested (of loading from a file and saving to a file) with the same results - memory consumed rises to just below 8GB after the constructor with the constructor finishing in 29777 milliseconds and the save taking 129816 milliseconds.

Snapshot - After constructor.png (68.7 KB)
Snapshot - After save.png (70.1 KB)

@leigh.rowland,
Thank you for the additional information. I am working on the issue you described.

@leigh.rowland,
To avoid misunderstandings and use the same approach, please share the code example you used to measure how long it would take to load and save the presentation.

@Andrey_Potapov - here is my code:

        string fileName = "C:\\Temp\\Latest Products Full.pptx";
        using (Stream documentBytes = new MemoryStream(File.ReadAllBytes(fileName)))
        {
            using (MemoryStream convertedFile = new MemoryStream())
            {
                System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
                sw.Start();
                using (Aspose.Slides.Presentation pres = new Aspose.Slides.Presentation(documentBytes))
                {
                    sw.Stop();
                    System.Diagnostics.Trace.WriteLine("Constructor - " + sw.ElapsedMilliseconds.ToString());
                    sw.Reset();
                    sw.Start();

                    pres.Save(convertedFile, Aspose.Slides.Export.SaveFormat.Pptx);
                    sw.Stop();
                    System.Diagnostics.Trace.WriteLine("Save - " + sw.ElapsedMilliseconds.ToString());
                }
            }
        }

@leigh.rowland,
Thank you for the code example. I’ve added a ticket with ID SLIDESNET-43355 to our issue tracking system. Our development team will investigate the case. We will inform you of any progress.

To reduce memory consumption while loading large presentations, you should consider a BLOB management.

Documents:
Open Large Presentation
Load a Large Presentation as BLOB

API Reference: LoadOptions class | BlobManagementOptions class