日期:2014-05-17  浏览次数:20821 次

求助,winform里面没问题,web里面内存泄露了。。

private List<Track> GetTrackList(string trackListUrl)
        {
            List<track> list = new List<track>();
            FileStream file = new FileStream(trackListUrl, FileMode.Open, FileAccess.ReadWrite);
            int b = Marshal.SizeOf(typeof(s_NV_FILEHEAD));
            byte[] buffer = new byte[b];
            file.Read(buffer, 0, b);
            s_NV_FILEHEAD gpsHead = (s_NV_FILEHEAD)RawDeserialize(buffer, typeof(s_NV_FILEHEAD));
            byte[] bytData = new byte[Marshal.SizeOf(typeof(s_NV_All))];
            List<s_NV_All> s = new List<s_NV_All>();
            while (file.Read(bytData, 0, bytData.Length) > 0)
            {
                s_NV_GPS_All all = (s_NV_All)RawDeserialize(bytData, typeof(s_NV_All));
                Track a = new Track
                {                   
                    Time = all.szTime
                };
                list.Add(a);
            }
            file.Close();
            return list;
        }
      
        private object RawDeserialize(byte[] rawdatas, Type anytype)
        {
            int rawsize = Marshal.SizeOf(anytype);
            if (rawsize > rawdatas.Length)
                return null;
            IntPtr buffer = Marshal.AllocHGlobal(rawsize);
            Marshal.Copy(rawdatas, 0, buffer, rawsize);
            object retobj = Marshal.PtrToStructure(buffer, anytype);
       &