RE: [DEV-C++] BUG: Dev-C 4.9.20 consolprogram has only access to 1MB memory.
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Ioannis V. <no...@ho...> - 2002-05-10 05:28:47
|
> -----Original Message-----
> From: staale [mailto:st...@le...]
> Sent: Friday, May 10, 2002 7:55 AM
> To: Ioannis Vranos; Dev-C++ Mailing List
> Subject: Re: [DEV-C++] BUG: Dev-C 4.9.20 consolprogram has
> only access to 1MB memory.
>
>
> Hi Ioannis,
>
> As I'm not a seasoned C++ programer I welcom your your work
> on my code, and
> your efforts in this mailing list.:o)
>
> To be shure I test again and with som simpler code and it
> still fails on a
> NT4-Sp6 (and w2k) with Dev-C 4.9.20 (Clean new installation
> of the computer,
> also the OS!!)
>
> I't works on a NT4-Sp6 with Dev-C 4.0
>
> See also the 'tread'
> [Dev-C++] not enough memory - how to configure Win2000
> which is the reaason form my involvement.
>
> ----------- Code -------------
> #include <stdlib.h>
>
> int main()
> {
>
> // 1MB = 1048576 = 1*1024*1024
> // 2MB = 2097152 = 2*1024*1024
> // 31MB = 32505856
> char narr[2097152];
>
> system("PAUSE");
> return 0;
> }
> ----------- Code End -------------
>
> Best Regards
> Staale Flock
I assume you mean that your code crashes, not the IDE.There is a limit
of the stack. It has nothing to do with the compiler.
Run this code to see the size of your stack:
#include <iostream>
void stack()
{
using namespace std;
static unsigned long counter=0;
char buffer[1024-sizeof(unsigned long)-1];
counter++;
cout<<"Allocated approximately "<<counter<<" KB of stack before i
die\n";
stack();
}
int main()
{
stack();
}
That's why for large arrays & objects we use the free store (new,
delete) or better the standard library containers such as vector.
Ioannis
* Ioannis Vranos
* Programming pages: http://www.noicys.cjb.net
* Alternative URL: http://run.to/noicys
|