Nick
Nick

Reputation: 31

Creating Array - Exception of type 'System.OutOfMemoryException' was thrown

I am using Visual Studio 2015 VB. net. When I try to create the following array, I get the error message

"Exception of type 'System.OutOfMemoryException' was thrown."

when the target CPU is x86 or AnyCPU.

When I set the target CPU to x64 the array is created fine.

Private maCombsNums As Integer(,,,,)
....
maCombsNums = New Integer(50, 50, 50, 50, 50) {}

Is this a bug? As I would like to run my program on a 32-bit windows system.

Upvotes: 1

Views: 387

Answers (1)

doctorlove
doctorlove

Reputation: 19252

To answer the question you asked, this is not a bug. You are asking for a lot of memory and x64 will be able to give you more.

You might be able to find a better data structure for your use case. For example, if the data is sparse you could use a lookup table (Dictionary) and just populate what you need.

Upvotes: 3

Related Questions