当我运行以下代码时,我将1.5 GB jpg图像插入List VideoType,但它使用20GB + Ram。我怀疑有些重复,但我不知道怎么做?
public class VideoType
{
public int VideoTypeId { get; set; }
public List<Bitmap> Bitmaps { get; set; }
}
CODE&gt;
List<VideoType> VideoTypes = new List<VideoType>();
for (int i = 0; i < X; i++)
VideoTypes.Add(VideoTypeGet(VideoTypeId)));
public static VideoType VideoTypeGet(int VideoTypeId)
{
VideoType VideoType = new VideoType();
List<Bitmap> Bitmaps = new List<Bitmap>()
for (int i = 1; i < X; i++)
Bitmaps.Add((Bitmap)Bitmap.FromFile(@"X"));
VideoType.Bitmaps = Bitmaps;
return VideoType;
}
答案 0 :(得分:2)
JPEG已压缩。位图未压缩。所以 - 你去吧。图像被解压缩并占用更多RAM。