how many elements can i add ?

i've got this struct:

1
2
3
4
5
struct something {                   
                   double x,y;               
                   double a,b;
                   long unsigned c;
                  } ;


then:

1
2
3
unsigned long dim=... ; 
something *p;
p = (something*)malloc(dim*sizeof(something));


my question is : how large can 'dim' be in order to get the program running and not be killed by OS or segmentation fault ?

by try/error i found about 4e7 elements to p array, that is dim=4e7
That'll depend on how much memory is available on your machine.
That depends on the memory availability for your program
i've got ~2GB free memory, enough for me to have around 4e8 elements, which is 10 times the amount i can now assign.
i only need, let's say 1e8 elements, which is 1/4 of the available memory, but it kills my process.

maybe i need to set a compiler parameter ?
i guess it's the machine...
i monitored the memory assigned to my app and for 4e7 elements the app used ~1.2GB memory, i guess i need a better machine for more elements. thank you. the post can now be closed.
If you have 32-bit Windows, you can usually not allocate more than 1.3 GB per process and if you have 32-bit Linux, you can generally not allocate more than 3 GB per process. These figures are unrelated to the amount of physical RAM you have.
Topic archived. No new replies allowed.