Mahesh Chitroda
Mahesh Chitroda

Reputation: 178

What is the Max size of Two Dimensional character array?

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?

Upvotes: 0

Views: 272

Answers (3)

JeffRSon
JeffRSon

Reputation: 11206

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.

Upvotes: 2

Tamim Al Manaseer
Tamim Al Manaseer

Reputation: 3724

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

Upvotes: -2

Mels
Mels

Reputation: 476

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.

Upvotes: 2

Related Questions