Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

how to dispose array

$
0
0

Hi,

I have this function that should be called multimple times.And i want to make sure that int[,] arrays be disposed / they dont use any memory at the end of the function.

privatebyte[,] sobel(byte[,] xms)
        {int[,] intpixelX = newint[720, 576];int[,] intpixelY = newint[720, 576];for (int y = 0; y < 288; y++)
            {for (int x = 360; x < 720; x++)
                {int one = xms[x - 1, y - 1] * (-1);int two = xms[x, y - 1] * (-2);int three = xms[x + 1, y - 1] * (-1);int four = xms[x - 1, y] * 0;int five = xms[x, y] * 0;int six = xms[x + 1, y] * 0;int seven = xms[x - 1, y + 1];int eight = xms[x, y + 1] * 2;int nine = xms[x + 1, y + 1];int result = one + two + three + four + five + six + seven + eight + nine;
                    intpixelY[x, y] = result;
                }
            }for (int y = 0; y < 288; y++)
            {for (int x = 360; x < 720; x++)
                {int one = xms[x - 1, y - 1] * (-1);int two = xms[x, y - 1] * 0;int three = xms[x + 1, y - 1];int four = xms[x - 1, y] * (-2);int five = xms[x, y] * 0;int six = xms[x + 1, y] * 2;int seven = xms[x - 1, y + 1] * (-1);int eight = xms[x, y + 1] * 0;int nine = xms[x + 1, y + 1];int result = one + two + three + four + five + six + seven + eight + nine;
                    intpixelX[x, y] = result;
                }
            }for (int y = 0; y < 288; y++)
            {for (int x = 360; x < 720; x++)
                {byte btowrite = (byte)Math.Sqrt((intpixelX[x, y] * intpixelX[x, y]) + (intpixelY[x, y] * intpixelY[x, y]));if (btowrite == 255)
                    {
                        xms[x, y] = 1;
                    }
                }
            }return xms;
        }
    }



Viewing all articles
Browse latest Browse all 31927

Trending Articles