How do I dispose an Image correctly? (Memory usage going up up up) #1290
-
Hey, I just use Imagesharp to Image.Load() a stream, then I mutate it, then I SaveAsPng(), and then it should be disposed by the using block. I don't need that image now anymore. But it seems to stay in memory. To be more specific, ConfigurableArrayPool+Bucket keeps getting bigger and bigger. I do this operation every minute or so and want to get rid of that pool after I'm done with one image. How? Here's some example code of how I use it, maybe I just do it wrong? ' Load
Using img = Image.Load(imgStream)
'Mutate
img.Mutate(Sub(x)
x.Resize(New ResizeOptions() With {
.Mode = ResizeMode.Pad,
.Size = New Size(2000, 1000),
.Position = AnchorPositionMode.Left
})
End Sub)
'Save
Using fs = IO.File.Create(imgPath)
img.SaveAsPng(fs, New Formats.Png.PngEncoder With {.CompressionLevel = 6})
End Using
' Close
End Using
' Why is there still stuff in memory at this point??? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 33 replies
-
You must be using an old version to be using VB.NET since the language does not support the Older versions contained a memory leak that was fixed back in January via #1074 Please note. We cannot support ImageSharp on VB.NET, nor can we support old versions. |
Beta Was this translation helpful? Give feedback.
-
Uhm, I'm on 2.7.0, is that not the current one? |
Beta Was this translation helpful? Give feedback.
-
@KoB-Kirito the answer for your question is here: Does it help? Is there anything left unexplained? |
Beta Was this translation helpful? Give feedback.
-
My spagetthicode is open source, if it helps. WIP though. |
Beta Was this translation helpful? Give feedback.
@KoB-Kirito the answer for your question is here:
https://docs.sixlabors.com/articles/imagesharp/memorymanagement.html
Does it help? Is there anything left unexplained?