View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
CraigFarnden CraigFarnden is offline
external usenet poster
 
Posts: 1
Default "Out of Memory" error

I have a VBA based model that creates very large arrays. It ran OK in nExcel
2002 and 2003, but the first time I tries to run it in Excel 2007 I got an
"Out of Memory" error. This appears to happen as memory is being allocated to
arrays when the simulation is first being initiated.

To try to isolate the problem, I created a very simple macro that does
nothing except create a 2-dimensional array:

Dim Array1() as single
Sub TestArray()
ReDim Array1(10000, 10000)
' Pause here using break point to check memory usage
in Task Manager
Erase Array1
End Sub

Increasing the array dimension too much above 10000 x 10000 results in the
"out of Memory" error. Prior to running the macro, Task Manager lists Excel
using about 27,000 K of memory.
Pausing the program part way with the array set at 10000 x 10000, Excel is
using 420,000 K. At 15000 x 11500, the memory usage was 740,000 K. At 15000
x 12000, I got the error.

I tried the same thing in Excel 2003 and got similar results, although with
a slightly larger array size before the error popped up.

It was my understanding that Excel 2002 and 2003 were limited to accessing a
maximum of 1 GB of RAM, while Excel 2007 was limited only by the physical
RAM. If that were the case, shouldn't my array size limits be much larger
running Excel 2007? Or is there still a memory size limit with VBA?

Old machine where my simulator worked: Pentium 4, 2 GB RAM, XP pro SP2,
Office 2003

New Machine where simulator encounters "Out of Memory" error: AMD Athlon
Dual Core, 4 GB RAM, XP Pro x64 SP2, Office 2007

Any thoughts?