最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

gcAllowVeryLargeObjects is not effective for using more than 2GB in an array in C# Asp.NET - Stack Overflow

programmeradmin0浏览0评论

I have struct as following

public struct Data
{
    public readonly long Start;
    public readonly long End;

    public Data(long start, long end)
    {
        Start = start;
        End = end;
    }
}
Data[] dataRange = new Data[150000000]; // here thrown "array dimensions exceeded supported range" exceptions. 

Array declaration supported only up to a length of 134217724. I assume 2GB is still limited even though it has gcAllowVeryLargeObjects enabled.

The same array is working fine with my separate ConsoleApplication whereas not working in Asp project.

I have struct as following

public struct Data
{
    public readonly long Start;
    public readonly long End;

    public Data(long start, long end)
    {
        Start = start;
        End = end;
    }
}
Data[] dataRange = new Data[150000000]; // here thrown "array dimensions exceeded supported range" exceptions. 

Array declaration supported only up to a length of 134217724. I assume 2GB is still limited even though it has gcAllowVeryLargeObjects enabled.

The same array is working fine with my separate ConsoleApplication whereas not working in Asp project.

Share Improve this question asked Mar 13 at 9:35 Gowtham DharmarajanGowtham Dharmarajan 2343 silver badges17 bronze badges 5
  • Are you sure you are running in x64? What version of ASP.Net are we talking about? – JonasH Commented Mar 13 at 10:03
  • @JonasH Environment.Is64BitOperatingSystem : true, Environment.Is64BitProcess : true, Debug setting is X64 & targetFramework is also 4.5 later. – Gowtham Dharmarajan Commented Mar 13 at 10:16
  • What is Array.MaxLength ? – JonasH Commented Mar 13 at 10:52
  • @JonasH How to check? – Gowtham Dharmarajan Commented Mar 13 at 11:22
  • The same way you check any other runtime property, like writing the property value to a logfile or run use an attached debugger to inspect the value. – JonasH Commented Mar 13 at 12:06
Add a comment  | 

1 Answer 1

Reset to default 0

For Asp web sites, we need to add gcallowverylargeobjects key in the C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\machine.config file to <runtime> section. web.config is not enough.

发布评论

评论列表(0)

  1. 暂无评论