SixLabors.ImageSharp.Formats.Webp.Lossy.Vp8Encoder.Encode: Experiencing High Native Memory Allocation in Release Mode (and not Debug) #3191
|
I am experiencing an issue over the past few days that I would like some guidance in diagnosing before I report it. To explain the situation, I am running a data migration tool that is converting approximately 120GB of image data from v1 to v2 of our product. I am running In Debug mode, this seems to behave as expected: managed memory is around ~350-450MB and the total memory hangs at about 1GB maximum, dropping as low as 550MB. I can confirm that When I run the application in Release mode, however, I see wildly different results. Managed memory again stays at around ~350-450MB but the total memory utilization will continually increase and explode up to 26GB after about 10 minutes of runtime. I have been using ReSharper/dotTrace to help out, and it seems this is happening in the following area: Again it seems that I am disposing of all Images as I am not too familiar with this (unmanaged) area so if I can get some guidance on how to proceed, I would greatly appreciate it. I will do my best to get you the information required. Thank you for any assistance in helping to track down this issue. |
Replies: 1 comment 2 replies
|
Thanks for the detailed report. The trace does not show a native memory leak, and it does not show ImageSharp holding 26 GB. Here is why. The numbers in the call tree are cumulative. dotTrace sums every allocation made while profiling. "All Calls 41,596 MB" is the total allocated over the whole run, not the memory in use. That number cannot be compared with a live process-memory reading. The tree shows managed allocations, not native ones. Frames such as
Debug and Release run the same ImageSharp binary. Only your own code, the JIT, and throughput change. A Debug run under the debugger is much slower. Ten minutes of Debug processes far fewer images than ten minutes of Release. Please compare both modes after the same number of images, not after the same time. To find the actual source of the growth, I need the following:
If neither experiment changes the total, the memory is outside ImageSharp. In that case, please check the |

Hi @JimBobSquarePants thank you for the really quick reply! I really appreciate it, along with the detailed analysis of Debug vs. Release. I agree with your explanation.
You're also 100% correct about dotTrace's reporting. I may have gotten a little bedazzled by its analysis, since this isn't a scenario I've had to dive into much. But you are correct; its reporting is managed and has nothing to do with unmanaged (though from the outset I was thinking the managed was somehow contributing to the unmanaged).
However, all that said, I am happy to report that after several days of hunting around, I finally found the reason for my grief, and it has nothing to do with ImageSharp:
https://github.…