Resize in parallel throws AccessViolationException or gives artifacts
See original GitHub issueI’m getting some problems when I try to resize copies of an image multiple times in parallel. I’ve tried making a console application as simple as possible that demonstrates my issue:
class Program
{
static void Main()
{
var originalFilepath = "C:\\original.png";
var outputPath = "C:\\resized";
Func<int, string> outputFilepath = i => $"{outputPath}\\{i}.png";
var n = 1000;
var width = 100;
var height = 100;
System.IO.Directory.CreateDirectory(outputPath);
using (var originalImage = new MagickImage(originalFilepath))
{
var tasks = new List<Task>();
for (int i=0;i<n;i++)
{
tasks.Add(ResizeAsync(originalImage, width, height, outputFilepath(i)));
}
Task.WhenAll(tasks).Wait();
}
}
static async Task ResizeAsync(MagickImage originalImage, int width, int height, string outputFilepath)
{
await Task.Delay(1);
using (var resizeImage = new MagickImage(originalImage))
{
resizeImage.Resize(width, height);
resizeImage.Write(outputFilepath);
}
}
}
If I run the above code using this image as original image: I will either get an AccessViolationException or get a number of resized images with artifacts such as:
I’m using Visual Studio 2015 and Magick.NET-Q8-AnyCPU
7.0.7.300
Issue Analytics
- State:
- Created 6 years ago
- Comments:13 (7 by maintainers)
Top Results From Across the Web
Resizing images in parallel causing out of memory exception
Originally I was using Image.FromFile() but doing some research, I found that Image.FromStream() is the way to go. I think I have the ......
Read more >Il2CppInspector Tutorial: Working with code in IL2CPP DLL ...
Many IL2CPP methods require some back-end thread structures to be set correctly or they will throw an access violation exception.
Read more >https://raw.githubusercontent.com/dotnet/samples/m...
XPathObject<T> is throwing a FormatException when the value passed is ... Parallel Tests are Failing on AppVeyor Machines The following 5 tests are...
Read more >Unity 2023.2.0b5
Fixed in 2023.2.0b7. Graphics Device Features: Rendering artifacts using Custom Render Texture shader on Sphere Game Object (UUM-43540).
Read more >Vaa3D and Vaa3D-Neuron: help
I want to quantify the number of vessels in my 3D images. First I run the Neuron Tracing utility of Vaa3D, this gives...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Using build 7.0.7.700 still yields the same kind of artifacts (I tried the console application above).
@ExplicitlyImplicit The new release was published yesterday, could you give it another try?