I'm trying to declare an array in a vb6 application that is a little larger than 2GB in size; it gets an "out of memory" error at run time. I distilled the application down to a single Dim (removing all code), as shown below:
Code:
' "comment out" one of these two:
' Private A(1 To &H65F00000) As Byte ' works with this active
Private A(1 To &H66000000) As Byte ' fails with this active
The app runs when the first line is used, and fails at run time (NOT at compile time) with an "out of memory" message when the second line is used.
It looks like there is some kind of 2GB limit on the size of an application at run time.
It doesn't help if I divide the array in half and put the two arrays in separate modules.
It doesn't help if I assign the arrays dynamically at run time.
I looked here for some specification from Microsoft, but saw nothing pertinent.
Am I correct that there is a 2GB limit on application size? Where is it specified?
What is the easiest workaround?
- Use a system call to allocate memory and address it manually (would this be exempt from the 2GB limit?)
- Call two separate custom DLLs, each containing half of the array
- Some other technique I haven't thought of