-
Mar 13th, 2021, 01:04 PM
#1
Thread Starter
Fanatic Member
Error "Out of Memory"
Before running any code, it returns out of memory (trying to run it in the IDE), I checked it isjust by the dimensionality of module's variables.
Like
DIM I (12, 16384, 2048) as integer
how many memory is available for variables in VB6? it doesn't look that it is 4GB or something near to that.
It looks like 512MB for variables ? how to know which is the limit, and how many I already have in use?
The memory space for var declarations (var headers) is the same space for allocating strings?
-
Mar 13th, 2021, 01:32 PM
#2
Re: Error "Out of Memory"
u could try 12x16384x2048 and DIM it one dimensional and you will get the same error.
integer is x2 so u can use twice the size for bytes.
but it seems to be around 266800000 for integer. not sure why this number.
-
Mar 13th, 2021, 01:38 PM
#3
Thread Starter
Fanatic Member
Re: Error "Out of Memory"
Originally Posted by baka
u could try 12x16384x2048 and DIM it one dimensional and you will get the same error.
integer is x2 so u can use twice the size for bytes.
but it seems to be around 266800000 for integer. not sure why this number.
Private a(12, 2048, 2048) '= out of memory ' Variants? = ????
Private a(12, 2048, 2048) as integer ' = OK run. = 50MB reserved for integers.
Just empty new project.
-
Mar 13th, 2021, 01:41 PM
#4
Thread Starter
Fanatic Member
Re: Error "Out of Memory"
Ok
Private a(12, 2048, 2048) As Integer
Private b(12, 2048, 2048) As Integer
Private c(12, 2048, 2048) As Integer
Private d(12, 2048, 2048) As Integer
Private e(12, 2048, 2048) As Integer
Private f(12, 2048, 2048) As Integer
Private g(12, 2048, 2048) As Integer
Private h(12, 2048, 2048) As Integer
Private i(12, 2048, 2048) As Integer
Private j(12, 2048, 2048) As Integer
= 500MB reserved for integer '= Ok, RUN!.
maybe it is a internal limit inside the var header structure.
-
Mar 13th, 2021, 01:46 PM
#5
Re: Error "Out of Memory"
Type MyPack
a() As Integer
b() As Integer
c() As Integer
End Type
Dim I As MyPack
ReDim I.a(12)
ReDim I.b(16384)
ReDim I.c(2048)
ok this works. it seems dynamic works, but not static.
Last edited by baka; Mar 13th, 2021 at 01:50 PM.
-
Mar 13th, 2021, 03:41 PM
#6
Thread Starter
Fanatic Member
Re: Error "Out of Memory"
Originally Posted by baka
Type MyPack
a() As Integer
b() As Integer
c() As Integer
End Type
Dim I As MyPack
ReDim I.a(12)
ReDim I.b(16384)
ReDim I.c(2048)
ok this works. it seems dynamic works, but not static.
Your code is not right. Yours will do 12+16k+2k and not 12*16k*2k
-
Mar 13th, 2021, 04:07 PM
#7
Re: Error "Out of Memory"
yeah u right. but I couldn't assign 12,16k,2k static. only dynamically.
so theres a limit here as u say.
what about using dynamic, but using multiple UDT? one above the other?
-
Mar 13th, 2021, 04:27 PM
#8
Addicted Member
Re: Error "Out of Memory"
You could try making the VB6.EXE Large Address Aware;
Attachment 180566
Code:
c:\program files (x86)\microsoft visual studio\vb98>editbin /LARGEADDRESSAWARE vb6.exe
Microsoft (R) COFF/PE Editor Version 14.28.29337.0
Copyright (C) Microsoft Corporation. All rights reserved.
This should give the VB6 IDE more memory on an X64 OS.
Joe
Last edited by Joe Caverly; Mar 13th, 2021 at 04:32 PM.
-
Mar 13th, 2021, 05:01 PM
#9
Addicted Member
Re: Error "Out of Memory"
-
Mar 14th, 2021, 03:47 AM
#10
Addicted Member
Re: Error "Out of Memory"
You Can use Arrays of Arrays:
In a class named ArrayClass
Code:
Private pArray(12) As Variant
Private Sub Class_Initialize()
Dim i As Long
Dim k As Long
For i = 0 To 12
pArray(i) = GetArray1
Next i
End Sub
Private Function GetArray1() As Variant()
Dim x(16384) As Variant
Dim i As Long
For i = 0 To 16384
x(i) = GetArray2
Next i
GetArray1 = x
End Function
Private Function GetArray2() As Integer()
Dim x(2048) As Integer
GetArray2 = x
End Function
Public Property Get Item(ByVal i As Integer, ByVal j As Integer, ByVal k As Integer) As Integer
Attribute Item.VB_UserMemId = 0
Item = pArray(i)(j)(k)
End Property
Public Property Let Item(ByVal i As Integer, ByVal j As Integer, ByVal k As Integer, ByVal value As Integer)
pArray(i)(j)(k) = value
End Property
now this code works:
Code:
Private Sub Form_Load()
Dim x As ArrayClass
Set x = New ArrayClass
x(1, 1, 1) = 23
Debug.Print x(1, 1, 1)
End Sub
the problem is that only the last dimension could be Integer, and don't think it has a great performance
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|