Results 1 to 10 of 10

Thread: Error "Out of Memory"

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2013
    Posts
    894

    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?

  2. #2
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,721

    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.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2013
    Posts
    894

    Re: Error "Out of Memory"

    Quote Originally Posted by baka View Post
    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.

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2013
    Posts
    894

    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.

  5. #5
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,721

    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.

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2013
    Posts
    894

    Re: Error "Out of Memory"

    Quote Originally Posted by baka View Post
    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

  7. #7
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,721

    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?

  8. #8
    Addicted Member
    Join Date
    May 2012
    Location
    42.787034,-81.176367
    Posts
    130

    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.

  9. #9
    Addicted Member
    Join Date
    May 2012
    Location
    42.787034,-81.176367
    Posts
    130

  10. #10
    Addicted Member gilman's Avatar
    Join Date
    Jan 2017
    Location
    Bilbao
    Posts
    176

    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
  •  



Click Here to Expand Forum to Full Width