相关疑难解决方法(0)

.NET数组的开销?

我试图使用以下代码确定.NET数组(在32位进程中)标头的开销:

long bytes1 = GC.GetTotalMemory(false);
object[] array = new object[10000];
    for (int i = 0; i < 10000; i++)
        array[i] = new int[1];
long bytes2 = GC.GetTotalMemory(false);
array[0] = null; // ensure no garbage collection before this point

Console.WriteLine(bytes2 - bytes1);
// Calculate array overhead in bytes by subtracting the size of 
// the array elements (40000 for object[10000] and 4 for each 
// array), and dividing by the number of arrays (10001)
Console.WriteLine("Array overhead: {0:0.000}", 
                  ((double)(bytes2 - bytes1) - …
Run Code Online (Sandbox Code Playgroud)

.net c# arrays overhead

36
推荐指数
2
解决办法
7944
查看次数

在哪里设置<gcAllowVeryLargeObjects>?

我正在研究一个关于排序列表的小程序.现在,我需要一个需要超过2GB RAM的阵列.在我的研究期间,我找到了这个属性,但我不知道在哪里设置它.我正在使用Mono.

c# arrays mono

8
推荐指数
1
解决办法
9014
查看次数

Azure 中的 System.OutOfMemoryException 但不是本地的

我有以下代码,它使用名为 Aspose.Words 的第三方库:

SaveOptions saveOptions = SaveOptions.CreateSaveOptions(SaveFormat.Docx);
saveOptions.MemoryOptimization = true;
saveOptions.TempFolder = Path.GetTempPath();
var mm = new RecyclableMemoryStreamManager();
using (RecyclableMemoryStream ms = new RecyclableMemoryStream(mm))
{
    doc.Save(ms, saveOptions);
    return ms.ToArray();
}
Run Code Online (Sandbox Code Playgroud)

我在using语句中遇到以下错误。

Mvc.ExceptionHandling.AbpExceptionFilter - 引发“System.OutOfMemoryException”类型的异常。

我无法在本地重现它(在处理过程中我的内存使用量可能增加了 200mb,因此它实际上并没有使用太多内存)。文件本身大小仅为 56MB。Aspose 告诉我它最多可以使用该数量的 10 倍......即使如此也应该没问题。我已更改服务计划以扩展到 14GB 内存。

我正在使用 RecyclableMemoryStreamManager 因为我已经尝试使用 MemoryStream 但没有成功。

我还能做些什么来解决这个我只在 Azure(开发和生产)中遇到的问题?Azure API是.net核心堆栈,具有64位平台。

提前致谢。

memorystream out-of-memory azure aspose.words

5
推荐指数
1
解决办法
2万
查看次数

标签 统计

arrays ×2

c# ×2

.net ×1

aspose.words ×1

azure ×1

memorystream ×1

mono ×1

out-of-memory ×1

overhead ×1