FileOnQ / Imaging.Heif

A C#/.NET wrapper around libheif for decoding and processing high efficiency image formats (heif, heic).
GNU Lesser General Public License v3.0
15 stars 4 forks source link

.NET 4.8 Memory Leak #65

Closed kenny-sellers closed 2 years ago

kenny-sellers commented 2 years ago

Description

It was discovered that we are seeing a memory leak in FileOnQ.Imaging.Heif when targeting .NET 4.8. Both the thumbnail (234B) and primary image (234B) are impacted. Below is the benchmarks.

Method Mean Error StdDev Gen 0 Gen 1 Gen 2 Allocated Allocated native memory Native memory leak
Thumbnail_Write 29.09 ms 0.211 ms 0.187 ms - - - 74,504 B 5,125,345 B 234 B
Thumbnail_ToArray 28.79 ms 0.171 ms 0.160 ms - - - 74,504 B 5,124,925 B 234 B
Thumbnail_ToSpan 29.12 ms 0.258 ms 0.215 ms - - - - 5,124,909 B 234 B
Thumbnail_ToStream 29.11 ms 0.366 ms 0.343 ms - - - 140,816 B 5,124,925 B 234 B
Method Mean Error StdDev Gen 0 Gen 1 Gen 2 Allocated Allocated native memory Native memory leak
PrimaryImage_Write 1.342 s 0.0043 s 0.0038 s - - - 1,951,112 B 222,030,860 B 234 B
PrimaryImage_ToArray 1.343 s 0.0031 s 0.0028 s - - - 1,951,112 B 222,030,552 B 234 B
PrimaryImage_ToSpan 1.342 s 0.0057 s 0.0053 s - - - - 222,029,928 B 234 B
PrimaryImage_ToStream 1.341 s 0.0043 s 0.0038 s - - - 3,894,032 B 222,030,392 B 234 B
SkyeHoefling commented 2 years ago

Thanks for writing this up @kenny-sellers

This was identified as part of #62