Results 1 to 9 of 9

Thread: [RESOLVED] How can I create a larger Array?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2009
    Posts
    86

    Resolved [RESOLVED] How can I create a larger Array?

    I have been developing a program in VB 2017 where I am able to create a (5 x 30000000) integer array.

    I want to increase the big dimension by a factor of about 10. 32 bit VB 2017 won't let me do it.

    So I downloaded 64 bit VB 2022 thinking I could create and use a larger array.

    VB 2022 will let me create the array but throws an out of memory exception when I try to use it.

    I am running 64 bit Windows 10 Pro and have 32 GB of memory but only 2.7 GB are being allocated to process memory.

    I don't have much experience with VB 2022. How can I fix this?

    Jerry

  2. #2
    PowerPoster PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Pontypool, Wales
    Posts
    2,958

    Re: How can I create a larger Array?

    Check your application settings, you might have it set to build as a 32 bit application or have 32 bit preferred.

    Building as a 64 but might solve the problem, not actually near my pc at the moment though so I can't test it.

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: How can I create a larger Array?

    You can't. Array dimensions cannot be greater than Int32.MaxValue. Even if you call Array.CreateInstance and pass an Int64 value, it still cannot be greater than Int32.MaxValue, or so the documentation says.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,102

    Re: How can I create a larger Array?

    And therefore you need to create multiple arrays and use a bit of math to figure out which array to index. Arrays are simple beasts. Ultimately, they are just sequential sequences of bytes. Even if you have five dimensions (why do you have five dimensions, that's usually a mistake?) you don't have some kind of square block of memory, you just have a long sequence of bytes with the compiler figuring out how to add and multiply the indices you supply to get to the memory you want. You can do the same thing, and if you want a block of memory too large for the array to index, then you will have to.
    My usual boring signature: Nothing

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jan 2009
    Posts
    86

    Re: How can I create a larger Array?

    Thank you for the feedback.

    Shaggy Hiker, multiple array looks doable.

    I have two dimensions in this example but I have used small five dimensional arrays in the past.


    Thanks again for pointing me in the right direction.

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Jan 2009
    Posts
    86

    Re: How can I create a larger Array?

    Shaggy Hiker,

    I just figured out what you meant by five dimensions. You meant five one dimensional arrays.

    The reason for such large arrays if that I have to analyze five channel .WAV files that are recorded at 256,000 samples per second in each channel. I need to process all five channels at the same time so a (5, X) array is convenient but can only holds about 120 seconds of data. The recordings I am working on now are 300 seconds long and I may get longer ones in the future.

    I tried creating four (5, x) arrays and the program now allocates 4.9 GB of process memory and runs with no exceptions. Now I need to create the code to make use of these other arrays.

  7. #7
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    9,017

    Re: [RESOLVED] How can I create a larger Array?

    I'm curious, why not load the WAV files a piece at a time? I am assuming of course you are trying to load the whole thing in memory.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Jan 2009
    Posts
    86

    Re: [RESOLVED] How can I create a larger Array?

    Hi Niya,


    The programs that I have running now load and process the wave files a piece at a time. I am trying to speed up the process.

    Some of the analysis involves comparing waveforms at different points in time and on different channels. I want switching back and forth to be as fast as possible.

    Disk read is slow so I think having it all in memory is the way to go.

    If you have a better idea let me know.

    Thank you

  9. #9
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    9,017

    Re: [RESOLVED] How can I create a larger Array?

    You may want to take a look at memory mapped files. No promises though. It may or may not make things simpler for you. It really depends on the details of what you're doing.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

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