alas I'm too much of a noob to fully understand what you wrote in your post about dynamic allocation, but you provided some keywords I will now try and use to study the matter.
Will get bach to this thread after understanding more.
Thanks again.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Local/auto variables are instantiated on the thread stack, which is typically about 2Mb (total for all variables on the stack). Large arrays have to be instantiated statically or dynamically.
double blubbo* = new double[256000]; // dynamic allocation in C++
double blubbo = malloc( 256000 * sizeof(blubbo) ) ; // dynamic allocation in C
In C++ you can also use a container class such as std::vector
Any variable defined outide of a function or class has static allocation in any case, in this case the static keyword refers to static linkage not static allocation (it makes the variable local to the module).
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello, new user here.
I tried searching the forum for this answer but, probabluy to my fault, I did not find a relevant topic.
I am in need of using large arrays, say up to one million elements
Even if I cannot have them that big, I'd like to have the biggest possible anyway.
I am using Dev C++ 4.9.9.2, Win XP SP3 , Pentium 4, 3.12 GB RAM.
Well, each time I try to declare a double type array longer than 255000 elements, the program crashes.
Just declaring something like:
double blubbo[256000];
is enough.
This is the upper limit; i.e. it works if I do nothing else apart declaring the array, no other variables declared.
If I declare other arrays, the limit gets even lower.
It is probably a memory issue; is there a way to allocate more RAM or whatever to these arrays ?
Thanks for your patience.
Thank you;
alas I'm too much of a noob to fully understand what you wrote in your post about dynamic allocation, but you provided some keywords I will now try and use to study the matter.
Will get bach to this thread after understanding more.
Thanks again.
Local/auto variables are instantiated on the thread stack, which is typically about 2Mb (total for all variables on the stack). Large arrays have to be instantiated statically or dynamically.
static double blubbo[256000]; // static allocation
double blubbo* = new double[256000]; // dynamic allocation in C++
double blubbo = malloc( 256000 * sizeof(blubbo) ) ; // dynamic allocation in C
In C++ you can also use a container class such as std::vector
Any variable defined outide of a function or class has static allocation in any case, in this case the static keyword refers to static linkage not static allocation (it makes the variable local to the module).
Clifford