IRONSOFTWAREHOME

Fixing Memory Leaks in IronPDF

Curtis Chau
Curtis Chau
Updated: July 21, 2026

If you are experiencing an apparent memory leak in IronPDF, we want to know about it. Our most senior engineers will dog-pile onto a memory leak to work on a hot-fix once identified.

This is how to report a memory leak to support@ironsoftware.com :

1. Update to the latest IronPDF version

If you are not already, please update to the latest IronPDF version.

2. Make Sure You Have Disposed Your IDisposable Objects

The vast majority of reported memory leaks are caused by improper use of the .NET IDisposable interface.

If any .NET class has a Dispose() method - it is probably IDisposable and will require the developer to tell it when they are finished using it.

There is a common misunderstanding that C# is a "managed" language, requiring no developer responsibility to manage memory. Contrary to this belief, there are in fact many common .NET objects that developers fail to dispose of.

Failing to manually dispose of each IDisposable class instance can cause a memory leak in your code.

  • System.IO.Stream - which is returned by the PdfDocument.Stream property.
  • System.Drawing.Image / System.Drawing.Bitmap - which is returned by the PdfDocument.ToBitmap() method.
  • IronPdf.PdfDocument - itself is marked IDisposable as well, as it may contain unmanaged objects in our later 2021 - 2024 releases.

The most common solution

The best solution is often to use a using statement when referring to IDisposable objects.

using(var stream = myPdfDocument.Stream) {
    // Perform operations with the stream here
}

In C# 8, there is even a shorthand version without {} closures.

using var stream = myPdfDocument.Stream;
// Perform operations with the stream here

3. Collect Garbage

The Visual Studio debugger memory profiler may continue showing an increase even if nothing is wrong. When using a high RAM system, the .NET runtime may decide that it is more efficient to allow garbage to sit in memory until your system RAM is nearly full or even use a swap file to keep.

It is possible to manually instruct the .NET garbage collector to dispose of its unused objects at a safe point in your application lifecycle when:

  • Not rendering a PDF
  • An IDisposable object is open

One way to do this is:

System.GC.Collect(); // Invokes the garbage collector
System.GC.WaitForPendingFinalizers(); // Waits for the process to complete
System.GC.Collect(); // Optional: Runs additional collection to ensure all objects are cleared

After this, the memory usage graph should drop to a normal, but non-zero level.

4. If you still have a Memory Leak - Report It

This will be respected as an extremely high priority. Please read this guide, which explains how to find your log files and report your issue in such a way that additional information will not be requested.

This 3-minute read will help us reproduce your issue with 100% accuracy, ensuring we do not waste your time.

Engineering Request PDF

Thank you - No one likes memory leaks, including us. When working with "low-level" or system objects like HTML rendering, Interop, Graphics, and Streams, they do become possible. So let's fix them!

IronPDF has only become what it is today from listening to our users' bug reports and feature requests, so thank you for your support.

Curtis Chau
Technical Writer

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.

...
Read More

Ready to Get Started?

Nuget Downloads 21,105,021Version:2026.9just released

Get your free 30-day Trial Key instantly.
No credit card or account creation required
C# NuGet Library for PDF
Install with NuGet

Version: 2026.9

PM > Install-Package IronPdf
nuget.org/packages/IronPdf/
  1. In Solution Explorer, right-click References, Manage NuGet Packages
  2. Select Browse and search "IronPdf"
  3. Select the package and install
C# PDF DLL
Download DLL

Version: 2026.9

or download Windows Installer here.

  1. Download and unzip IronPDF to a location such as ~/Libs within your Solution directory
  2. In Visual Studio Solution Explorer, right click References. Select Browse, "IronPdf.dll"

Licenses from $999

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

OR
bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried Iron Suite
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required
C# NuGet Library for PDF
Install with NuGet

Version: 2026.9

PM > Install-Package IronPdf
nuget.org/packages/IronPdf/
  1. In Solution Explorer, right-click References, Manage NuGet Packages
  2. Select Browse and search "IronPdf"
  3. Select the package and install
C# PDF DLL
Download DLL

Version: 2026.9

or download Windows Installer here.

  1. Download and unzip IronPDF to a location such as ~/Libs within your Solution directory
  2. In Visual Studio Solution Explorer, right click References. Select Browse, "IronPdf.dll"

Licenses from $999