Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21153

Massive 2D Array Out of Memory Error

$
0
0
I want to create a massive size two dimensional array such as a large 2D tile map, but ran into a limitation I think VB6 has. See my computer has over 8 gigs of memory. I know of computers out there that have even more memory such as custom built gaming pcs. But seriously, you mean to tell me that VB6 can't create a simple 10000 x 10000 array?

vb Code:
  1. Option Explicit
  2.  
  3. Dim A() As Long
  4. Dim W As Long
  5. Dim H As Long
  6.  
  7. Private Sub Form_Load()
  8.     W = 10000
  9.     H = 10000
  10.    
  11.     ReDim A(W - 1, H - 1) As Long
  12. End Sub

Hit play and youll see you'll get Out of Memory error. Not sure if there is a way around that, such as API's like CopyMemory, VarPtrArray, etc. Or even the SafeArray technique. I'll see if it works with them. But why is it severely limited? What is the limitation? I saw on another site that its limited to the range of a Long data type 2,147,483,647, but its wrong because 10000x10000 is 100,000,000, which is no where near the range of the Long data type.

Viewing all articles
Browse latest Browse all 21153

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>