The memory leak can be fixed by using the MattingImage instead of the hairmaskraw directly!
using var cihairmask = new CIImage(hairmaskraw.MattingImage);Read more here: dotnet/macios#19518 (comment)
This repo reproduces the AVSemanticSegmentationMatte memory leak of 2,98 MB.
This memory leak specifically happens in the code below:
var hairmaskraw = photo.GetSemanticSegmentationMatte(AVSemanticSegmentationMatteType.Hair);Furthermore, there is also a bug where the code line above only works for the first 4 images. Then it stops working and returns null for images taken after.
Use Apple Instruments software and run an "Allocation" test on the repo. This will show the the memory leak.
