using System;
using System.Collections;
using System.Text;
using System.ComponentModel;namespace CSHARP测试释放资源
{
    class Matrix
    {
        private double[,] data;        public Matrix(double[,] d)
        {
            int row = d.GetLength(0);//d数组的行
            int col = d.GetLength(1);//d数组的列            data = new double[row, col];            for (int i = 0; i < row; i++)
            {
                for (int j = 0; j < col; j++)
                {
                    data[i, j] = d[i, j];
                }
            }
        }    }    class Program 
    {      
        static void Main(string[] args)
        {
            Console.WriteLine("测试释放对象资源程序\n");            double[,] d =new double[10000,1000];            Matrix mtr = new Matrix(d);            mtr = null;  GC.Collect();
        }
    }
}如上,定义一个类Matrix,再申明对象mtr ,我这样写只是做一个示范,我用的释放方法很粗俗很不专业:
mtr = null;  GC.Collect();
这样在小程序中运行发现内存的确能够释放,但是我写的较大软件(6000行代码)
发现这种释放方法太痤了,而且有时候根本不能释放!!请教前辈,如上代码作何修改??
感激不尽!!