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

ToSpan Allocates Extra Bytes in .NET 5 and .NET 6 #75

Open SkyeHoefling opened 2 years ago

SkyeHoefling commented 2 years ago

Description

In both .NET 5 and .NET 6 benchmarks the ToSpan has extra allocations that don't make sense. This API wraps the native pointer from the encoders project and it shouldn't be creating any additional allocations. See benchmark table below.

The benchmarks have been ran on different machines the important value is the memory allocation Method Mean Error StdDev Allocated native memory Native memory leak Allocated
Thumbnail_ToSpan (NET 5) 58.68 ms 1.150 ms 1.889 ms 5,123,597 B - 120 B
PrimaryImage_ToSpan (NET 5) 2.981 s 0.0252 s 0.0236 s 222,028,216 B - 88 B
Thumbnail_ToSpan (NET 6) 47.54 ms 0.425 ms 0.398 ms 5,123,853 B - 600 B
PrimaryImage_ToSpan (NET 6) 2.968 s 0.0271 s 0.0241 s 222,029,080 B - 616 B