Martin Nelson
Martin Nelson

Reputation: 9

VB6 Maximum Size of an Array

Dear StackOverflow USers!

I recently came across an unusual need to solve a problem in VB6. I have developed an application where I need to temporarily store very large volumes of data into the memory. Since classes and class members talke up more resources and more important need more time to unload, I came across the idea to use arrays. However is seems not to be possible to use all the available RAM on my computer. Could anyone give me an idea of how I could solve this?

Thank you!

Upvotes: 1

Views: 10808

Answers (2)

Adrian
Adrian

Reputation: 2364

The array size limit in VB6 is the highest value of a signed 32-bit integer, or 2,147,483,647 elements.

That should actually be enough to cover the full address space for a 32-bit program, but this is unlikely to use the full RAM allocation of a modern computer running a 64-bit OS.

Had you considered writing this processing step in another language that supports a 64-bit address space, and just executing this program from within your VB6 program?

I actually ran into the same problem with VB3, which only permitted arrays 2^15-1 elements large, which was a real drag - just under 33,000 elements made memory sorting of many systems impractical.

Upvotes: 1

Mark Bertenshaw
Mark Bertenshaw

Reputation: 5689

It depends on what you mean by "all the RAM on your computer". If you are using the VB6 compiler, being 32-bit, you are only ever going to be able to use 2G of RAM as standard, because that is the maximum amount of memory that VB6 can address at a time. It may be possible to hack the executable to take advantage of 3G on a /3G windows or Win64 machine using EDITBIN.EXE, but I would be surprised if it worked.

Your best bet is to write the data to a temporary file. You should use CreateFile() / ReadFile() WinAPI calls to do file access, because VB6 has the same 2G limitation on file sizes.

Upvotes: 1

Related Questions