約3000枚以上の画像を処理する必要のあるc#コードをいくつか作成しましたが、500枚目の画像までに、タスクマネージャーは1.5GBのメモリを使用してプログラムを表示しています。以下の機能は、主な原因の1つと思われます。ここで何がうまくいくでしょうか?ヘルプや提案をいただければ幸いです。ありがとう。
private void FixImage(ref Bitmap field)
{
//rotate 45 degrees
RotateBilinear rot = new RotateBilinear(45);
field = rot.Apply(field); //Memory spikes 2mb here
//crop out unwanted image space
Crop crop = new Crop(new Rectangle(cropStartX, cropStartY, finalWidth, finalHeight));
field = crop.Apply(field); //Memory spikes 2mb here
//correct background
for (int i = 0; i < field.Width; i++)
{
for (int j = 0; j < field.Height; j++)
{
if (field.GetPixel(i, j).ToArgb() == Color.Black.ToArgb())
field.SetPixel(i, j, Color.White);
}
} //Memory usuage increases 0.5mb by the end
}