I am running into issues with Aspose.PSD leaving a large amount of allocated memory when the portion of my code that actually uses Aspose finishes. I am not sure why it is not being cleaned up by GC for many reasons including the facts that the class that utilizes Aspose is disposed of and the thread that the class and Aspose runs on gets terminated before a GC collection is called. The following image is a screenshot of a diagnostic session with the program. At about 3:34 is when the thread Aspose is running on is terminated and where the memory usage should go down but doesn’t. In the Call Tree, Aspose.PSD.Image.Save takes the most memory by far with another large memory hog being a function (not in the screenshot) that analyzes the int[] returned by Aspose.PSD.RasterImage.LoadArgb32Pixels.
image.png (109.2 KB)
I have tried various solutions to this issue, but none have shown any progress. The program is intended to be used to export individual layers as .pngs if that helps at all. I have attached the diagnostic file here: Memory Leak Issue - Google Drive
Edit: I added an example .psd file to the above Google Drive. It is a version of the .psd file the screenshot is taken from with all the rasterized image layers being turned to all white or all black. It still has the memory issue though.
@Skeletax
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): PSDNET-2154
Could you please additionally provide minimum required code to reproduce the issue.
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
@Dmitriy.Sorokin I have uploaded my code to the Google Drive in the initial post, quoted below as well.
I’ve update Task with your code sample. Thank you, you will be notified when the issue will be fixed, or if there can be any workaround.
Hello,
I’m experiencing what looks like a memory leak when using Aspose.PSD 25.8 in my production application. I work in the school and sports photography industry, and my application processes large volumes of PSDs to create package sheets.
Problem
- Sports jobs in particular use many PSD templates, and the same PSDs are reused multiple times while creating packages.
- As the job progresses, my application’s memory usage climbs steadily until most of the available RAM is consumed.
- Profiling shows large numbers of
PsdImage
, Layer
, ChannelInformation
, and related objects staying alive. They appear to be retained through a static Dictionary<object,object>
inside Aspose.PSD.
- Even after I call
Dispose()
on every PsdImage
and associated stream, memory is not released.
What I’ve tried
- Verified that my code disposes every
PsdImage
, Stream
, and any other disposable resource.
- Disabled my own caching (I now only cache PSD bytes, not Aspose objects).
- Forced .NET GC with LOH compaction after each batch — some memory is reclaimed, but most of the objects remain rooted.
Observation
Visual Studio’s memory profiler shows:
- Roots leading back to
Dictionary<object,object> [Static variable]
, with entries referencing PsdImage
and its layers.
- This suggests Aspose.PSD is internally caching or retaining PSD object graphs, and those caches are not being cleared on
Dispose()
.
Question
- Is this expected behavior?
- Is there a supported way to clear or reset Aspose.PSD’s internal caches/dictionaries at a time of my choosing (for example, after finishing a set of packages)?
- If not, is there a recommended strategy to prevent unbounded memory growth in long-running processes that repeatedly load many PSDs?
Any guidance or best practices would be appreciated.
Screenshot 2025-09-03 190939.png (51.2 KB)
@joshuasmith it’s better to create a new ticket. Then I can add issue in our internal system and you’ll be notified when the issue will be fixed. After quick look, I’ve found uncommon marker in our Test Build Log that may indicate Memory Leak. But we need to investigate this. Did you tried older versions?
Apologies, I’ll see if I can create a new ticket. I’ve only tried 25.7 and 25.8