Re: "virtual memory exhausted: Out of memory" with a large static array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Pavel Saviankou writes:

 > i would like to compile a programm, which contains an static array with a 
 > large amount of structures(containts 9 doubles) as elements. I try it on two 
 > ways. 
 > 
 > One way is: 
 > I put as an element the structure as 
 > mystruct array[823543] = { .., { 0.,0.,0.,0.,0.,0.,0.,0.,0.}, ... }
 > and try to compile.
 > (Number of elements CAN and WILL be much larger. this is only fewdata test)
 > 
 > 
 > First I try the "g++ (GCC) 4.1.2 20070115 (prerelease) (SUSE Linux)" and -O0.
 > The compilation breaks with  "virtual memory exhausted: Out of memory".
 > The same result, even if i turn on the optimisation -O1,2,3,4,5 and a lot of 
 > flags -fxxx .-
 > 
 > Then i try the "g++ (GCC) 3.4.5".
 > It compiles,  both with -O0 and with -O1,2,3,4,5!
 > 
 > The second way is:
 > I create 823543 (or even more) structures with the name like struct1, struct2 
 > and so on
 > 
 > mystruct struct1 = { 0.,0.,0.,0.,0.,0.,0.,0.,0.};
 > mystruct struct2 = { 0.,0.,0.,0.,0.,0.,0.,0.,0.};
 > ..
 > and the array with the pointers on they:
 > mystruct * array[823543] = { &struct1, &struct2, ...};
 > 
 > Now i get the "virtual memory exhausted: Out of memory" with both
 > versions of compiler and with both optimisations settings.
 > 
 > The source with the structures and array will be generated
 > automatically.  With a small amount of structures - i have no
 > problems, but i have to have a large, more than 100 000 000 numbers
 > of structures, amount of data.

This will indeed run out of memory during compilation.  Why not read
the data into your array at runtime?

Andrew.

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux