I am a beginner in programming and for the first "harder" project I choose to make a tool to search for doubles in my picture collection.
My first thought was to use hashes so I came up with this:
var files = Directory.GetFiles("T:Obrazki", "*.jpg");
foreach (var item in files)
{
var m = Image.FromFile(item);
Console.WriteLine(m.GetHashCode());
}
It starts pretty well and then gives the System.OutOfMemoryException.
I tried many things including dividing the loop into 2 for loops, but with no effect. Next I found online a piece of advice to change the Target Platform to x64 which I did and nothing helped.
The last thing I tried was to dispose of 'm' every iteration of the loop and to manually add GC.Collect:
var files = Directory.GetFiles("T:Obrazki", "*.jpg");
foreach (var item in files)
{
var m = Image.FromFile(item);
Console.WriteLine(m.GetHashCode());
m.Dispose();
GC.Collect();
}
It didn't work aswell. It crashes after +/- 180 images. Do you have any ideas how to do this?