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

Fixes Native Memory Leaks #27

Closed SkyeHoefling closed 3 years ago

SkyeHoefling commented 3 years ago

Fixes: #21

Description

Fixes memory leak when writing IImage to storage, the output image was never released. Added new native API invocation to release native image memory.

Merge Checklist

github-actions[bot] commented 3 years ago

Benchmark Comparison

Benchmarking comparison between this Pull Request and the comitted values at benchmarks/results

thumbnail

 No differences found between the benchmark results with threshold 10%.

primary

 summary:
better: 1, geomean: 1.174
total diff: 1

No Slower results for the provided threshold = 10% and noise filter = 0.3ns.

| Faster                                                          | base/diff | Base Median (ns) | Diff Median (ns) | Modality|
| --------------------------------------------------------------- | ---------:| ----------------:| ----------------:| -------- |
| FileOnQ.Imaging.Heif.Benchmarks.PrimaryImage.PrimaryImage_Write |      1.17 |    2947325900.00 |    2509865500.00 | several?|

No file given

Benchmark Results

thumbnail

``` ini BenchmarkDotNet=v0.13.0, OS=Windows 10.0.17763.2114 (1809/October2018Update/Redstone5) Intel Xeon CPU E5-2673 v4 2.30GHz, 1 CPU, 2 logical and 2 physical cores .NET SDK=5.0.400 [Host] : .NET 5.0.9 (5.0.921.35908), X64 RyuJIT Job-ONQKLS : .NET 5.0.9 (5.0.921.35908), X64 RyuJIT Runtime=.NET 5.0 InvocationCount=1 LaunchCount=1 UnrollFactor=1 ``` | Method | Mean | Error | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated | Allocated native memory | Native memory leak | |---------------- |---------:|---------:|---------:|------:|------:|------:|----------:|------------------------:|-------------------:| | Thumbnail_Write | 66.20 ms | 1.317 ms | 3.078 ms | - | - | - | 280 B | 5,125,137 B | - |

primary

``` ini BenchmarkDotNet=v0.13.0, OS=Windows 10.0.17763.2114 (1809/October2018Update/Redstone5) Intel Xeon CPU E5-2673 v4 2.30GHz, 1 CPU, 2 logical and 2 physical cores .NET SDK=5.0.400 [Host] : .NET 5.0.9 (5.0.921.35908), X64 RyuJIT Job-TNXGEV : .NET 5.0.9 (5.0.921.35908), X64 RyuJIT Runtime=.NET 5.0 InvocationCount=1 LaunchCount=1 UnrollFactor=1 ``` | Method | Mean | Error | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated | Allocated native memory | Native memory leak | |------------------- |--------:|---------:|---------:|------:|------:|------:|----------:|------------------------:|-------------------:| | PrimaryImage_Write | 2.536 s | 0.0501 s | 0.0954 s | - | - | - | 248 B | 222,029,996 B | - |

SkyeHoefling commented 3 years ago

Confirmed benchmarks above show - for Native memory leak, this means the leaks are fixed