CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    May 2017
    Posts
    2

    Question about array memory

    If I use

    Global VarCol(144000,450) as double, I will get no out of memory in VB6 Windows 10

    But if I use Global VarCol(144000,500) as double, the out of memory pops up. It's only a array of 144001 x 501 x double = 577 MB and I have 32GB of memory, so I don't understand that there isn't room enough for this array.

    I understood I could use arrays up to 2Gb.


    Thanks in advance

  2. #2
    Join Date
    May 2017
    Posts
    2

    Re: Question about array memory

    Help!!

  3. #3
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    Re: Question about array memory

    I don't know/use VB6 so this is an educated guess. Memory is allocated from 2 places - stack and heap. Stack memory is usually allocated for fixed size variables when the size is known at compile time. Heap (or dynamic) memory is usually allocated when the size is only determined at run-time. There is a limit to how much stack memory is available - irrespective of how much actual physical memory is available. Without knowing VB6 I'm guessing that the VB6 compiler is trying to allocate the memory for VarCol on the stack and is running out of stack memory. Is there a way in VB6 to dynamically allocate memory for an array at runtime?

    Sorry I can't be more help - I only use c++ and VB6 might do things very different. In c++ I can allocate an array of 144000 x 500 OK.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  4. #4
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: Question about array memory

    Always use [code][/code] tags when posting code.

Tags for this Thread

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

Featured