Huge arrays?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Michael Gray

    #1

    Huge arrays?

    VS 2003
    VB.net
    Win2000 SP4

    The System.Array class seems to be limited to 32 bit addresses,
    meaning that one can only assign 2^32 elements.

    Is there any way that I can have an array that allows 2^64 elements?
    Or doesn't the CLR support this on a 32 bit opsys?
    I suspect that I am going to have to make such a beastie myself...

    What about sparse arrays?
  • Robin Tucker

    #2
    Re: Huge arrays?


    Can I ask what you want to use such a beast for?



    "Michael Gray" <fleetg@newsguy .spam.com> wrote in message
    news:d85qc15ajv el34r4coc8ebmkj bgeh1mn68@4ax.c om...[color=blue]
    > VS 2003
    > VB.net
    > Win2000 SP4
    >
    > The System.Array class seems to be limited to 32 bit addresses,
    > meaning that one can only assign 2^32 elements.
    >
    > Is there any way that I can have an array that allows 2^64 elements?
    > Or doesn't the CLR support this on a 32 bit opsys?
    > I suspect that I am going to have to make such a beastie myself...
    >
    > What about sparse arrays?[/color]


    Comment

    • Inge Henriksen

      #3
      Re: Huge arrays?

      Use a database to store this many elements, as collections are also limited
      by an Integer. You could ofcourse use several arrays or collections.

      "Michael Gray" <fleetg@newsguy .spam.com> skrev i melding
      news:d85qc15ajv el34r4coc8ebmkj bgeh1mn68@4ax.c om...[color=blue]
      > VS 2003
      > VB.net
      > Win2000 SP4
      >
      > The System.Array class seems to be limited to 32 bit addresses,
      > meaning that one can only assign 2^32 elements.
      >
      > Is there any way that I can have an array that allows 2^64 elements?
      > Or doesn't the CLR support this on a 32 bit opsys?
      > I suspect that I am going to have to make such a beastie myself...
      >
      > What about sparse arrays?[/color]



      Comment

      • Jay B. Harlow [MVP - Outlook]

        #4
        Re: Huge arrays?

        Michael,
        In addition to the other comments:

        | The System.Array class seems to be limited to 32 bit addresses,
        | meaning that one can only assign 2^32 elements.
        ..NET 1.1 has "support" for large arrays in that there is an Array.LongLengt h
        property (Int64) & Array.GetValue & Array.SetValue are overloaded for Long
        (Int64).

        http://msdn.microsoft.com/library/de...engthTopic.asp

        http://msdn.microsoft.com/library/de...alueTopic3.asp

        | Is there any way that I can have an array that allows 2^64 elements?
        | Or doesn't the CLR support this on a 32 bit opsys?
        However! other then sparse arrays, which I'm not sure how much support
        there is, how would you actually allocate said array? Remember that under 32
        bit OS you can only index 4G of memory, of which the OS wants to keep 2G (1G
        on some OSes) for itself, the runtime, your code, the stack, and other data
        is going to use up part of the usable 2G, so the actually size of an Array
        is going to be much smaller.

        If I truly needed an "array" that is larger the 512M or so, I would consider
        defining a new Type that used a file for the actual backing of the data &
        read & write each element as needed. I would consider caching the elements
        if performance became a problem. You could define this Type such that it
        behaved like most normal collections.

        Alternatively I have defined "Sparse Arrays", where I keep the "index" &
        elements in a HashTable...


        BTW: .NET 2.0 http://lab.msdn.microsoft.com/vs2005/ includes both a 32bit &
        64bit runtime, so on a 64bit OS with the 64bit runtime you can have
        obnoxiously large arrays... Whether you should or not is another discussion
        ;-)

        Hope this helps
        Jay

        "Michael Gray" <fleetg@newsguy .spam.com> wrote in message
        news:d85qc15ajv el34r4coc8ebmkj bgeh1mn68@4ax.c om...
        | VS 2003
        | VB.net
        | Win2000 SP4
        |
        | The System.Array class seems to be limited to 32 bit addresses,
        | meaning that one can only assign 2^32 elements.
        |
        | Is there any way that I can have an array that allows 2^64 elements?
        | Or doesn't the CLR support this on a 32 bit opsys?
        | I suspect that I am going to have to make such a beastie myself...
        |
        | What about sparse arrays?


        Comment

        • Michael Gray

          #5
          Re: Huge arrays?

          On Thu, 7 Jul 2005 11:20:04 -0500, "Jay B. Harlow [MVP - Outlook]"
          <Jay_Harlow_MVP @msn.com> wrote:
          [color=blue]
          >Michael,
          >In addition to the other comments:
          >
          >| The System.Array class seems to be limited to 32 bit addresses,
          >| meaning that one can only assign 2^32 elements.
          >.NET 1.1 has "support" for large arrays in that there is an Array.LongLengt h
          >property (Int64) & Array.GetValue & Array.SetValue are overloaded for Long
          >(Int64).
          >
          >http://msdn.microsoft.com/library/de...engthTopic.asp
          >
          >http://msdn.microsoft.com/library/de...alueTopic3.asp
          >
          >| Is there any way that I can have an array that allows 2^64 elements?
          >| Or doesn't the CLR support this on a 32 bit opsys?
          >However! other then sparse arrays, which I'm not sure how much support
          >there is, how would you actually allocate said array? Remember that under 32
          >bit OS you can only index 4G of memory, of which the OS wants to keep 2G (1G
          >on some OSes) for itself, the runtime, your code, the stack, and other data
          >is going to use up part of the usable 2G, so the actually size of an Array
          >is going to be much smaller.
          >
          >If I truly needed an "array" that is larger the 512M or so, I would consider
          >defining a new Type that used a file for the actual backing of the data &
          >read & write each element as needed. I would consider caching the elements
          >if performance became a problem. You could define this Type such that it
          >behaved like most normal collections.
          >
          >Alternativel y I have defined "Sparse Arrays", where I keep the "index" &
          >elements in a HashTable...
          >
          >
          >BTW: .NET 2.0 http://lab.msdn.microsoft.com/vs2005/ includes both a 32bit &
          >64bit runtime, so on a 64bit OS with the 64bit runtime you can have
          >obnoxiously large arrays... Whether you should or not is another discussion
          >;-)
          >
          >Hope this helps
          >Jay[/color]

          Ah, that's the answer that I was looking for...
          Thanks to the other posters as well.

          I knew that this rather strange request would prompt the same reaction
          that I initially had: Why? and wouldn't you be better off doing it
          another way?
          The answers to which are: It was an enquiry to eliminate lingering
          doubts, and Yes.

          I really only wanted huge sparse arrays, ala FORTRAN, but noticed
          these 64 bit addressing functions for System.Array objects(Getvalu e &
          SetValue), but was then thrown by not being able to index them as
          such, except via these special functions.

          They "appeared" to have 64 bit addressing, only very much "under the
          hood" as it were.

          It just seemed strange to me that Microsoft would go to all the
          trouble of allowing 64 bit addresses in System.Array, and then going
          through hoops to cover it up, by forcing the default indexing schemes
          to 32 bit! (At least in VB.Net anyway)

          Thanks for all your replies, problem will be solved another way...

          Comment

          • Michael Gray

            #6
            Re: Huge arrays?

            On Thu, 7 Jul 2005 13:37:42 +0100, "Robin Tucker"
            <idontwanttobes pammedanymore@r eallyidont.com> wrote:
            [color=blue]
            >
            >Can I ask what you want to use such a beast for?
            >[/color]
            I don't really, but want huge sparse arrays, such as FORTRAN provides.
            See my other reply for more info...

            Comment

            • Michael Gray

              #7
              Re: Huge arrays?

              On Thu, 7 Jul 2005 16:30:23 +0200, "Inge Henriksen"
              <inge.henriksen @booleansoft.co m> wrote:
              [color=blue]
              >Use a database to store this many elements, as collections are also limited
              >by an Integer. You could ofcourse use several arrays or collections.[/color]
              :
              Thanks for taking the time to reply.
              See my lengthier response to J.B. Harlow for more details, if you are
              interested.

              Comment

              Working...