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 staticDictionary<object,object>
inside Aspose.PSD. - Even after I call
Dispose()
on everyPsdImage
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 referencingPsdImage
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)
Screenshot 2025-09-03 185346.png (9.5 KB)