large arrays and system.outofmemoryexception

G

Guest

assuming I have 2GB memory. And 1.5GB available.

dim c1(,) as byte
redim c1(1000, 1024*1024)

throws system.outofmemoryexception. I'm like... huh? Initially I thought a
lot of space is taken up by GC. So, I up my memory to 4GB. Same thing....

So, I read microsoft documents on this type of exception. Doesn't help much.
They were saying to try and keep arrays to 64KB. But, that's not much to work
with.

I suspected that it's gotta do with 'available contiguous memory' and not
just the total available memory. For example,

redim c1(800, 1024*1024)
redim c2(200, 1024*1024)
may work but not...
redim c1(500, 1024*1024)
redim c2(500, 1024*1024)

can someone shed some light on this? Sound like a .net memory oddity. ASP
..net seems to have similar problem (not with arrays though)
 
G

Guest

hey Cor, thanks for the reply.

Ah, the /3GB thing. Yes, that was the first thing I tried after upping the
memory from 2 to 4GB. Didn't work though. But, I seriously doubt that it's
got anything to do with total memory.

I think that .net just can't handle arrays that size :(

Before I upped the memory, outofmemoryexception crashed out at 800MB of
array size. After upping to 4GB, it's still 800MB. So, I don't think it's the
total physical memory. I investigated page file size too, as well as stopping
unnecessary processes. Same thing. Oh well, sounds like recoding is the way
to go. I'm just curious why it's like this.
 
H

Herfried K. Wagner [MVP]

chad said:
Before I upped the memory, outofmemoryexception crashed out at 800MB of
array size. After upping to 4GB, it's still 800MB. So, I don't think it's
the
total physical memory. I investigated page file size too, as well as
stopping
unnecessary processes. Same thing. Oh well, sounds like recoding is the
way
to go. I'm just curious why it's like this.

IIRC ~ 800 MB was the per-process memory limit for .NET 1.*, and maybe still
is for .NET 2.0.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top