AllocationLimitMegabytes seems not to be followed with GIF's #2799
-
Before creating an actual issue I wanted to check if I'm missing something crucial. A while ago I learnt from James that you can set a limit of the max allocation for an image. I was playing with this and one of my co-workers created a GIF that still allocates 6Gb of RAM even while I configured the limit on 192Mb. I guess this works per frame? Or is this a bug and should I create an issue? Sincerely, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
My recommendation would be to either set int totalImageLimitInBytes = 192 * 1024 * 1024;
ImageInfo info = await Image.IdentifyAsync(...);
int frameCount = info.FrameMetadataCollection.Count;
if (info.Width * info.Height * frameCount * sizeof(Rgba32) > totalImageLimitInBytes)
{
throw new Exception("Image too large.");
} Note: we shall probably consider a built-in feature to achieve the above. |
Beta Was this translation helpful? Give feedback.
AllocationLimitMegabytes
only limit a single allocation while gif-s are multi frame / multi buffer objects.My recommendation would be to either set
DecoderOptions.MaxFrames
, or useImage.Identify(Async)
before decoding to set a limit for the overall image allocation before decoding:Note: we shall probably consider a built-in feature to achieve the above.