Stack overflow
-
I'm going by memory, too, but I think the default stack is 1 Meg but you can set it to be a different size as part of the build. I've never personally done it though. :suss:
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
Tim Craig wrote:
but you can set it to be a different size as part of the build.
yeah, that is very plausible, however I never have done so for a Windows app. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
-
I'm going by memory, too, but I think the default stack is 1 Meg but you can set it to be a different size as part of the build. I've never personally done it though. :suss:
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
Tim Craig wrote:
but you can set it to be a different size as part of the build.
yeah, that is very plausible; it is common practice for embedded systems, however I never have done so for a Windows app. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
-
I have trouble with declaring my array size so as to avoid the stack overflow error: _variant_t raw_data[10000][100] _variant_t results[10000][100] i read somewhere about dynamic sizing, i tried this but it didnt work _variant_t *raw_data = new _variant_t [10000][100] any help would be very much appreciated..
Try with malloc, that can used to represent multidimensional array.
int **nArray;
int nRows = 10000;
int nColumn = 100;
nArray = (int**)malloc(nRows * sizeof(int *));
ZeroMemory( nArray, 0 );
if( 0 == nArray )
{
return 0;
}
for(int i = 0; i < nRows; i++)
{
nArray[i] = (int*)malloc( nColumn * sizeof(int));
if( 0 == nArray[i] )
{
return 0;
}
}Величие не Бога может быть недооценена.
-
I'm going by memory, too, but I think the default stack is 1 Meg but you can set it to be a different size as part of the build. I've never personally done it though. :suss:
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
You remember well [^]. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
You remember well [^]. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]I remember a poem in Mad Magazine in the late 50's that went "I remember, I remember...", but I can't remember what they remembered. :sigh:
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
-
I remember a poem in Mad Magazine in the late 50's that went "I remember, I remember...", but I can't remember what they remembered. :sigh:
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
You are lucky. On the other hand: "I don't remember, I don't recall I got no memory of anything at all" :-D
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
I have trouble with declaring my array size so as to avoid the stack overflow error: _variant_t raw_data[10000][100] _variant_t results[10000][100] i read somewhere about dynamic sizing, i tried this but it didnt work _variant_t *raw_data = new _variant_t [10000][100] any help would be very much appreciated..
so i tried this but keep getting errors on _variant_t *p line: **************************************************** initialize array vector<_variant_t> d(10000); //_variant_t** 2d = new _(variant_t*)[10000]; for(long k = 0; k < d.size(); ++k) { d[k] = new _variant_t(); *********************************************************** delete array for(k = 0; k < d.size(); ++k) { _variant_t* p = d[k]; (error = cannot convert from 'class _variant_t' to 'class _variant_t *') delete [] p; }
-
so i tried this but keep getting errors on _variant_t *p line: **************************************************** initialize array vector<_variant_t> d(10000); //_variant_t** 2d = new _(variant_t*)[10000]; for(long k = 0; k < d.size(); ++k) { d[k] = new _variant_t(); *********************************************************** delete array for(k = 0; k < d.size(); ++k) { _variant_t* p = d[k]; (error = cannot convert from 'class _variant_t' to 'class _variant_t *') delete [] p; }
hi, use vector<_variant_t*> d(10000); instead of vector<_variant_t> d(10000);
-
hi, use vector<_variant_t*> d(10000); instead of vector<_variant_t> d(10000);
Thanks it worked but even after compiling the code, i still get stack overflow: this is how am declaring my array:
static const int N = 9990; static const int N2 = 96; vector<_variant_t*> d(N); for(long k = 0; k < d.size(); ++k) { d[k] = new _variant_t(); } _variant_t raw_data[N][N2]; _variant_t filter_results[N2]; _variant_t results2[N][N2] _variant_t Filtered_Average[N];
-
Thanks it worked but even after compiling the code, i still get stack overflow: this is how am declaring my array:
static const int N = 9990; static const int N2 = 96; vector<_variant_t*> d(N); for(long k = 0; k < d.size(); ++k) { d[k] = new _variant_t(); } _variant_t raw_data[N][N2]; _variant_t filter_results[N2]; _variant_t results2[N][N2] _variant_t Filtered_Average[N];
you are trying to create a multidimenional array on stack. normally stack has a limitation of 2MB but heap can go upto around 100 MB. create all the variables in heap and importantly delete it after using. this is a classic multi dimension c++ mem allocation. sample : _variant_t **raw_data[N]; for(int nOut = 0;nOut < N;nOut++) { raw_data[nOut] = new _variant_t*[N2]; for(int nIn = 0;nIn < N2;nIn++) { raw_data[nOut][nIn]= new _variant_t(nIn);// sample initialization } } // delete this is important for(int nOut = 0;nOut < N;nOut++) { for(int nIn = 0;nIn < N2;nIn++) { delete raw_data[nOut][nIn]; } delete raw_data[nOut] ; }