如何在 visual studio C# 中增加桌面应用程序使用的内存以避免 MemoryOutOfBound 异常

How to increase memory used desktop application in visual studio C# to avoid MemoryOutOfBound exception

我正在使用 Emgu 库从一组图像创建视频, 大多数时候,当我 运行 程序生成 MemoryOutOfBound 异常时,使用 videoWriter() 的代码部分如下所示

p = dp.FileName + ".avi";
VideoWriter v = new VideoWriter(p, 24, hd.Width, hd.Height, true);
string filename = "";
int iiii = 0;
for (int j = 0; j < a; j++)
{
    filename="frames" + j + ".bmp";
    hdd = new Bitmap(jj + "\new1\" + filename);
    hd = new Image<Bgr, Byte>(hdd);
    v.WriteFrame(hd);
}
v.Dispose();

如果您要求您的程序能够使用大量内存 (>2GB),则需要针对 x64 平台进行编译(并且 运行 在一个平台上)。 如果您需要大对象 (>2GB),您还需要将以下代码添加到您的 App.config 文件中:

<runtime>    
    <gcAllowVeryLargeObjects enabled="true" />
</runtime>

注意:我认为您需要 运行 .NET 4.5 或更高版本才能使用此功能