Menu

crash because of double f[1000000]

basti_b
2014-05-22
2014-05-24
  • basti_b

    basti_b - 2014-05-22

    Hi,

    I try to use a large double array, but here seems to be some overflow if I make it too large:

    #include <stdio.h>
    int main()
    {
        double f[1000000];       // produces crash
        double g[100000];        // works fine    
    }
    

    What's my problem? Is this supposed to be like that and if so, how can I use larger arrays?

    Thanks,
    basti_b


    Windows 7, Dev-C++ 5.4.0, TDM-GCC 4.7.1 64-bit

    Edit: added system information, changed 2nd array name to avoid misunderstandings

     

    Last edit: basti_b 2014-05-24
  • Merak

    Merak - 2014-05-22

    Answer fetched from stack overflow:

    If you have declared the array in local scope (inside some routine), size limit is determined by stack size. -If gcc is running on linux, the stack size is determined by some environment variable. Use ulimit -a to view and ulimit -s STACK_SIZE to modify the stack size.

    -If gcc is running on windows (like MinGW), stack size can be specified by gcc -Wl,--stack, STACK_SIZE.

    If you have declared the array in global scope, the array is stored in DATA or BSS section (based on whether the array is initialized or uninitialized respectively). The DATA and BSS section size are determined by underlying OS.

    If you have declared the array in static scope (like static int array[SIZE]), again, the array is stored in DATA or BSS section (based on whether the array is initialized or uninitialized respectively). The DATA and BSS section size are determined by underlying OS.

     
    • thesyntotic

      thesyntotic - 2014-05-23

      We spend a lot of time and do lots of efforts to manage such big
      things in computers! You want a flat address space; the bigger, the
      more OS oriented your solution will need be. No one tried to answer my
      question(s)? I am having trouble reading file lists in Windows...

      On 5/22/14, Merak mehrak@users.sf.net wrote:

      Answer fetched from stack overflow:

      If you have declared the array in local scope (inside some routine), size
      limit is determined by stack size. -If gcc is running on linux, the stack
      size is determined by some environment variable. Use ulimit -a to view and
      ulimit -s STACK_SIZE to modify the stack size.

      -If gcc is running on windows (like MinGW), stack size can be specified by
      gcc -Wl,--stack, STACK_SIZE.

      If you have declared the array in global scope, the array is stored in DATA
      or BSS section (based on whether the array is initialized or uninitialized
      respectively). The DATA and BSS section size are determined by underlying
      OS.

      If you have declared the array in static scope (like static int
      array[SIZE]), again, the array is stored in DATA or BSS section (based on
      whether the array is initialized or uninitialized respectively). The DATA
      and BSS section size are determined by underlying OS.


      crash because of double
      f[1000000]


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/dev-cpp/discussion/48211/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

      --
      Danilo J Bonsignore

       
    • basti_b

      basti_b - 2014-05-24

      Ok, I'll try that.
      Windows 7, by the way. Forgot to add it to my original post, I'm going to do that right now.

       
  • Merak

    Merak - 2014-05-23

    I don't understand the reply from Bonsignore?

    You are not the OP and if you don't understand the answer ( and consider it "not trying to answer" ) maybe you should consider something simpler to start with?

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.