0

I have one two dimensional array:

char[,] DataFile;

When I create a object:

DataFile=new char[45000,6000] 

It throws an out of memory exception.

What is the Max Size of object in .Net 3.5? What Is the Max Length of char array?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Mahesh Chitroda
  • 178
  • 2
  • 10

3 Answers3

2

Single objects still limited to 2 GB in size in CLR 4.0? already has quite a nice explanation of the limits in various circumstances.

Community
  • 1
  • 1
Mels
  • 476
  • 2
  • 17
2

Well, it depends.

Obviously it'll matter how much physical memory (RAM) you've got installed and/or how large you set up virtual memory (swap).

In any case, in 32bit Windows maximum object size is 2GB. But there's another limit: The process image must have a contiguous block of memory of the required size.

Your array is about 514MB large. You should check for yourself if you have sufficient resources available.

JeffRSon
  • 10,404
  • 4
  • 26
  • 51
-2

There is no actual limit, it just depends on how much RAM your computer has, and how much contiguous memory the runtime can allocate.

Tamim Al Manaseer
  • 3,554
  • 3
  • 24
  • 33