Where is this array stored in memory?

From: Dimitri (antoniou_at_aecom.yu.edu)
Date: 08/20/04

  • Next message: James Van Buskirk: "Re: Where is this array stored in memory?"
    Date: 19 Aug 2004 21:24:24 -0700
    
    

    Hi,

     I saw some unexpected behavior of memory allocation in a program.
     I am sure that the explanation is very simple,
     I just don't know how memory allocation works.
     I would be grateful if somebody could explain the following behavior.

     In my program I have an array that is allocated dynamically
     and has dimensions (1000,40000)
     [ this array is continuously updated after every iteration of a do-loop ]

     In two workstations, the program didn't compile at all,
     because there was no space to store the huge array.

     In another (Itanium) the program compiled and ran fine.
     But when I increased the size of the array even more, eg (1000,50000)
     it compiled but it ran extremely slowly.
     Judging from the noise of the hard disk spinning, the program temporarily
     wrote the array on disk after each iteration, or something like that.

     If we store double precision numbers in the (1000,40000) array,
     we occupy 32 Mb (is that right?)
     and for the (1000,50000) array we need 40 Mb
     I have 4 of the huge arrays, the other arrays in the program are small.

     My question:
     From the above behavior, it seems that the four 32 Mb arrays fit in some place
     in memory that eventually can't accomodate 4*40 Mb
     What is this place in memory?
     Can I increase its storage capacity from the command line?

     Also, when we dynamically allocate the four (1000,50000) arrays,
     I assumed that we reserve 4*40 Mb somewhere.
     But evidently the array somehow ends up being stored in the place
     mentioned in the previous paragraph, that can hold only 4*32 Mb.

     The processor was Itanium2 and the compiler was Intel 8.0 for Linux.
     I didn't post the program because it's quite long
     [a 40,000-timestep trajectory in a 1000-dimensional space is deformed
      after each iteration of a do-loop, so the huge array is this trajectory]

     Thanks,

     Dimitri


  • Next message: James Van Buskirk: "Re: Where is this array stored in memory?"

    Relevant Pages

    • Re: Where is this array stored in memory?
      ... antoniou@aecom.yu.edu (Dimitri) wrote ... ... > I saw some unexpected behavior of memory allocation in a program. ... > because there was no space to store the huge array. ... > wrote the array on disk after each iteration, ...
      (comp.lang.fortran)
    • Re: Convert C-Builder program to Delphi?
      ... It's a simple memory allocation for an array of uint8s, ... The simplistic Delphi equivalent is GetMem, ... While UINT8 is not equal to uint8 in C++, ...
      (comp.lang.pascal.delphi.misc)
    • Re: Convert C-Builder program to Delphi?
      ... It's a simple memory allocation for an array of uint8s, ... The simplistic Delphi equivalent is GetMem, ... While UINT8 is not equal to uint8 in C++, ...
      (comp.lang.cpp)
    • Re: Static allocation failure?
      ... Lets say I have an array that I declare statically in a function, ... but you are probably out of memory allocated to stack space! ... we tend to discourage users from declaring their arrays ... He apparently is unaware that there are basically three types of memory allocation in C - dynamic, static, and automatic. ...
      (comp.arch.embedded)
    • Re: Copying an array slice (Was: Re: Difficulties with passing multi-dimensional arrays)
      ... > the pointer to array of unknown size. ... but it still compiles without a cast. ... unknown at compile time so nothing can be checked. ...
      (comp.lang.c)