Maximum array size?

This is a discussion on Maximum array size? within the C Programming forums, part of the General Programming Boards category; There appears to be a hard limit to the maximum array size allowed by c compilers of 2 to the ...

  1. #1
    Registered User
    Join Date
    May 2004
    Posts
    8

    Maximum array size?

    There appears to be a hard limit to the maximum array size allowed by c compilers of 2 to the 29th.

    Can anyone confirm that this is a hard limit (no way to adjust it that is)?

    Has anyone ever ran into it before, and if so what did you do? Note that it isn't a simple case of an array of char or some simple type. The actual array declaration is only 256 elements, but each element is a huge structure of structures that in some cases increase in size proportionally to the 256 element array that contains them (geez). I only need to double the index of the array, but doing so kills my compile due to array index size.

    I know this is a pretty odd situation, but someone may have ran into something similar sometime (I hope).

  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,794
    Don't know about any absolute limit, but you might try compiler options/settings to increase the stack size. Also, is this data allocated within a function? You can try allocating it globally... or allocate it dynamically using malloc for instance. Those might be ways to get around that limit.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  3. #3
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >There appears to be a hard limit to the maximum array size allowed by c compilers of 2 to the 29th.
    There's a hard limit, but it varies with each implementation. Read your compiler's documentation for ways of increasing the stack size, or use heap allocation for your array.
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 05-29-2009, 07:25 PM
  2. How do you use variable to initialize array size?
    By yougene in forum C Programming
    Replies: 11
    Last Post: 09-04-2007, 02:50 PM
  3. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  4. Type and nontype parameters w/overloading
    By Mr_LJ in forum C++ Programming
    Replies: 3
    Last Post: 01-02-2004, 12:01 AM
  5. Struct *** initialization
    By Saravanan in forum C Programming
    Replies: 20
    Last Post: 10-09-2003, 12:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21