Out of memory error in processing large images of size 50 MB #579
System ConfigurationCode is running on AWS ECS container CPU 512MB , Hard/Soft Memory Limits 1024 MiB
QuestionI'm using MagickNet to process images and convert them to thumbnail. It works perfectly for images till 45 MB, But when i upload image of size 50 MB the aws ECS instance runs out of memory and the container restarts itself. Please find the below code using (var image = new MagickImage(bytes)) <<-- This line throws out of memory error in case of large files 50 Mb |
Replies: 12 comments 1 reply
|
Have you tried to set memory limit usage? Documentation Like this: |
|
hi all any help is highly appreciated. |
|
The size of the file does not really matter. The number of pixels determines how much memory you need. Can you clarify what you mean by "not working"? And can you share a file that demonstrates this issue. |
|
Thanks for the quick reply. ResourceLimits.LimitMemory(new Percentage(100)); it throws me an exception, |
|
just an update, the Same file im able to load using ImageMagick command line. |
|
In what kind of environment are you running this? Your images probably requires |
|
Thanks for the reply. The image im trying to load is a CMYK image, so i understand the Size to be 16000x10000x4. |
|
If you have a CMYK image you will indeed need to multiply it by 4. And that makes the total required memory 2.56 GB Is your .NET application running in a 32bit environment? That is the only reason I could think of why this would not work in your .NET application. What happens when you switch to the |
|
yes, my .Net application is in AnyCPU. |
|
Magick.Net-Q16-AnyCPU is supposed to support both x64 and x86, |
|
many thanks.. |
yes, my .Net application is in AnyCPU.
So now instead of Magick.Net-Q16-AnyCPU, i used Magick.Net-Q16-x64 , and now im able to load the image.