Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. upper limit for an array

upper limit for an array

Scheduled Pinned Locked Moved C / C++ / MFC
questioncsharpvisual-studiodata-structuresperformance
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tomaz Rotovnik
    wrote on last edited by
    #1

    What is an upper limit for dynamic allocation of single array? For an example: int* A_of_int = new int[X]; What is upper value for X. The environment is visual studio 6 on windows platform (XP). I suppose one of the limits is memory size.

    A 1 Reply Last reply
    0
    • T Tomaz Rotovnik

      What is an upper limit for dynamic allocation of single array? For an example: int* A_of_int = new int[X]; What is upper value for X. The environment is visual studio 6 on windows platform (XP). I suppose one of the limits is memory size.

      A Offline
      A Offline
      Anders Molin
      wrote on last edited by
      #2

      INT_MAX And of course avaliable memory. - Anders Money talks, but all mine ever says is "Goodbye!" ShotKeeper, my Photo Album / Organizer Application [^]

      My Photos[^]

      T 1 Reply Last reply
      0
      • A Anders Molin

        INT_MAX And of course avaliable memory. - Anders Money talks, but all mine ever says is "Goodbye!" ShotKeeper, my Photo Album / Organizer Application [^]

        My Photos[^]

        T Offline
        T Offline
        Tomaz Rotovnik
        wrote on last edited by
        #3

        Hi Perhaps I'm wrong but INT_MAX is defined as maximum int value 2^31-1 What I need is maximum array size for type int Is constant INT_MAX also used to define maximum array size for type int? Tomaz Rotovnik

        A 1 Reply Last reply
        0
        • T Tomaz Rotovnik

          Hi Perhaps I'm wrong but INT_MAX is defined as maximum int value 2^31-1 What I need is maximum array size for type int Is constant INT_MAX also used to define maximum array size for type int? Tomaz Rotovnik

          A Offline
          A Offline
          Anders Molin
          wrote on last edited by
          #4

          In reallity the avaliable memory is the only limit, as an array is just a pointer to some memory. Why do you need this limit? - Anders Money talks, but all mine ever says is "Goodbye!" ShotKeeper, my Photo Album / Organizer Application [^]

          My Photos[^]

          T 1 Reply Last reply
          0
          • A Anders Molin

            In reallity the avaliable memory is the only limit, as an array is just a pointer to some memory. Why do you need this limit? - Anders Money talks, but all mine ever says is "Goodbye!" ShotKeeper, my Photo Album / Organizer Application [^]

            My Photos[^]

            T Offline
            T Offline
            Tomaz Rotovnik
            wrote on last edited by
            #5

            I need an huge array and I want prevent application crash. I think I found the answer: max heap size is declared in malloc.h /* Maximum heap request the heap manager will attempt */ #define _HEAP_MAXREQ 0xFFFFFFE0 Tomaz Rotovnik

            A 1 Reply Last reply
            0
            • T Tomaz Rotovnik

              I need an huge array and I want prevent application crash. I think I found the answer: max heap size is declared in malloc.h /* Maximum heap request the heap manager will attempt */ #define _HEAP_MAXREQ 0xFFFFFFE0 Tomaz Rotovnik

              A Offline
              A Offline
              Anders Molin
              wrote on last edited by
              #6

              Tomaz Rotovnik wrote: #define _HEAP_MAXREQ 0xFFFFFFE0 That is 4GB, a lot more memory that most computers have... If you use malloc to alloc your array, the app will not crash, but you will get a NULL pointer if it fails. - Anders Money talks, but all mine ever says is "Goodbye!" ShotKeeper, my Photo Album / Organizer Application [^]

              My Photos[^]

              D 1 Reply Last reply
              0
              • A Anders Molin

                Tomaz Rotovnik wrote: #define _HEAP_MAXREQ 0xFFFFFFE0 That is 4GB, a lot more memory that most computers have... If you use malloc to alloc your array, the app will not crash, but you will get a NULL pointer if it fails. - Anders Money talks, but all mine ever says is "Goodbye!" ShotKeeper, my Photo Album / Organizer Application [^]

                My Photos[^]

                D Offline
                D Offline
                David Crow
                wrote on last edited by
                #7

                Anders Molin wrote: That is 4GB, a lot more memory that most computers have... Even if the computer had 8GB of RAM, the memory manager only allows each process 2GB for its address space, or 3GB if the /3GB startup switch were used. Anders Molin wrote: ...if it fails. That should be "when it fails."


                "When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups