-
Notifications
You must be signed in to change notification settings - Fork 205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
avifenc using high amount of memory #1111
Comments
Ok after more debugging it seems the issue is most likely the RAM usage. When we upgraded the EC2 instance to have 4GB we were able to convert it but the memory usage is spiking to almost 2GB. Is it normal that the memory usage is soo high for random images or is there a specific reason? |
Thanks for the report and investigation. The resolution of the images are one of the main components to memory usage and with animations the encoder will keep extra image-sized buffers to use as references. What were the sizes of the images in this case? |
The images were 2160x2160. The issue was indeed that the kernel killed the process as it was trying to use more memory than available. My main concern still is why it's using so much memory for so few files while files with same size are not needed that much memory. |
I have a large image coming in at around 375MB, about 40,000 x 30,000. This thing spikes to 9GB of RAM usage before dying. I can't get it to work :(
|
Hi @aentwist, could you share Note that a three-channel, 40,000 x 30,000 image is 3.35GB uncompressed. So if we have two copies of the uncompressed image in memory, that's 6.7GB already. The |
Line 614 in 471326f
libaom also limits the max_area to 1<<30: I tried with an image of:
I you use the "-autotiling" option, less RAM will be used. For now, that limits to 8 tiles though, cf Line 1708 in 471326f
but we could probably remove that lock as we limit to 32 tiles above anyway. |
Yeah I realized this image isn't really the best fit for this issue, because such an unusually large image comes with other problems. As for the RAM, it is over my head how a 375MB PNG expands to 3.5GB, but given that, the explanation of the RAM sounds fairly reasonable. My objective was only a nice-to-have so I just gave up on the conversion. Good luck should you decide to pursue this optimization. |
40000 x 30000 x 3 😉 |
Hi @aentwist, I have downloaded the The actual image size is 38464 x 28832. In addition to the high amount of memory, it may cause integer overflows in our code. So I will need to run our code under the Undefined Behavior Sanitizer and fix the integer overflows. (As Vincent noted, our code currently imposes a maximum image size of 2^30 to avoid the known integer overflows.) |
I found that the |
Fix signed and unsigned integer overflows when encoding a frame of size 38464 x 28832. For more information, see AOMediaCodec/libavif#1111 (comment). Change-Id: I78131498a198c5bd157bbb9fcdf5042ae71affc9
Let's use this issue for the high memory usage problem when encoding an AVIF image sequence (i.e., AVIF animation) that @GyllieGyllie originally reported. I filed #2271 for the support of large image size that @aentwist reported in #1111 (comment). |
We are running avifenc on AWS Lambda to convert single frame png images to a single AVIF image.
It works fine for most but we have some group of images where it just exits with no feedback at all.
We recompiled everything yesterday on the latest commit from the default branch.
Command ran that fails
We also tried to run the same command on another EC2 instance we have where we can see this
When finding the reason it says
The instance has 0.5GB ram, on lambda we have it set to 1GB. The images themselves are each ~250KB in size and 2160x2160px
The text was updated successfully, but these errors were encountered: