Thread: [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: staale <st...@le...> - 2002-05-10 01:42:50
|
Se also thread:
[Dev-C++] not enough memory - how to configure Win2000
on the mailing list. Test code below
Hi Helmuth,
Turns out this has somthing to do with Dev-C 4.9.20.
This is what I did to verify the problem:
1: Tried your file on both w2k (Clean system) or NT4-Sp6. It failed on both
machins.
2: I installed DEV-C 4.9.20 (downloaded today) on a clean w2k machine and
encountered the same problem when I compiled and ran the code.
3: Tried to uninstall DEV-C 4.9.20. Uninstal DOES NOT work. Delete the fiels
manualy. Search for dev-c in regedit.exe and then run RegClean.exe just
search for RegClean and you should be well of (Might not nead this see pkt
5)
4: Installed DEV-C 4.0 on the w2k machine Compiled and tested OK to 31MB.
5: Installed Dev-c 4.9.20 on top of the 4.0 and It still worked nicely..:o)
6: Installed Dev-C 4.9.20 on NT4-SP6 (Only Winzip appart from OS). Added
shlwapi.dll and wininet.dll to system32 folder. Tried to run the code but
no. Same failure.
7: Installed Dev-C 4.0 on top of the 4.9.20. This did not help. Brobably
because both installers does not overwrite existing header files (?). So you
should delete the 4.9.x installaation. Install 4.0 and then 4.9.x (if you
nead it. It is a must if you want to use the wxWindows lib, if I understand
right)
I'm not a seasoned C developer but would gues there are somthing wrong with
a header file or reference making dev-c 4.9.x compile to 16bit code(???)
Best regards
Staale Flock
------------------- Code
Start --------------------------------------------------------
////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////
// this code fails if you install Dev-C 4.9.20 on a new w2k machine and try
to access
// more than 1MB memory. (Enter any number higher than 1).
////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
const long MEGA_BYTE = 1024*1024;
long nMBSize = 1;
while (nMBSize != 0 ){
cout << "Give MB size: ";
cin >> nMBSize;
char narrBig[nMBSize * MEGA_BYTE];
cout << "char size: " << sizeof(char) << " Bytes." << endl;
cout << "Array size: " << sizeof(narrBig)<< " Bytes." << endl;
//See if initializing each element makes a difference
for (unsigned long i = 0; i<nMBSize*MEGA_BYTE;i++){
narrBig[i] = 'A';
}//i
cout << "Array size: " << sizeof(narrBig) << endl;
//If you store objects in the array remember to use:
delete []narrBig;
}//while (nMB..
//To have a breake before window closes, use:
system("PAUSE");
return 0;
}
------------------- Code end ---------------------------------
----- Original Message -----
From: <jar...@be...>
To: <st...@le...>
Sent: Thursday, May 09, 2002 11:48 AM
Subject: Re: [Dev-C++] not enough memory - how to configure Win2000
> On 8 May, staale wrote:
> > I have tried my sample program on a w2k machine now and it work al the
way
> > up to 31 (thats wher you meet the long border is it not)?
> >
> > If you send me your compiled binary, I'll giv it a try. (hmm, could be
> > during thge weekend as I'm sceduled for the next 48 houers.:o) Also if
you
> > search for the drwtsn32.log file. Giv it a new name, delete it or what
ever.
> > Run the test program again. And then include the drwtsn32.log file in
your
> > mail to me. I might be able to help a litle bit more. The drwtsn32.log
is a
> > simpel debug dump file (I think www.sysinternals.com has an articel on
how
> > to read it).
> >
> > A thought, how do you start the program? From the Dev-C IDE or in a
console
> > window? If you use start-run-command.exe I belive you will be runing a
nativ
> > DOS session. You should use start-run-cmd.exe (don't nead the exe part)
to
> > get flat memmory. The last is what you get if you double click the
> > pBigArray.exe from explorer.
>
> Unfortunately, this doesn't help either.
>
> Many thanks for looking into it,
> Helmut.
>
> --
> Helmut Jarausch
>
> Lehrstuhl fuer Numerische Mathematik
> Institute of Technology, RWTH Aachen
> D 52056 Aachen, Germany
>
|
|
From: Ioannis V. <no...@ho...> - 2002-05-10 02:52:05
|
Your code fixed:
#include <iostream>
//-->Not needed
// #include <stdio.h>
#include <stdlib.h>
//--> You do not use argc, argv[] so why you declare them?
int main(int argc, char *argv[])
{
using namespace std; // --> necessary
const long MEGA_BYTE = 1024*1024;
long nMBSize = 1;
while (nMBSize != 0 ){
cout << "Give MB size: ";
cin >> nMBSize;
//--> Illegal in ANSI C++. The sizes of arrays in the stack must be
constants
//--> char narrBig[nMBSize * MEGA_BYTE];
char *narrBig=new char[nMBSize*MEGA_BYTE];
//--> Useless. sizeof(char) is always 1 byte
//cout << "char size: " << sizeof(char) << " Bytes." << endl;
//-->You can't do that on an array on the free store.
// Here it returns the size of char *
// cout << "Array size: " << sizeof(narrBig)<< " Bytes." << endl;
//See if initializing each element makes a difference
for (unsigned long i = 0; i<nMBSize*MEGA_BYTE;i++){
narrBig[i] = 'A';
}//i
//--> Useless. cout << "Array size: " << sizeof(narrBig) << endl;
//If you store objects in the array remember to use:
delete [] narrBig;
//--> This could be disastrous when applied on a built in array as you
had done
}//while (nMB..
//To have a breake before window closes, use:
system("PAUSE");
return 0;
}
====
How i would do it in your case:
#include <iostream>
#include <cstdlib>
#include <vector>
int main()
{
using namespace std;
const unsigned long MEGA_BYTE = 1024*1024;
long nMBSize;
do
{
cout << "\nGive MB size: ";
cin >> nMBSize;
vector<char> narrBig(nMBSize*MEGA_BYTE);
cout << "Array contents size: " << narrBig.size()<< " Bytes." <<
endl;
for (unsigned long i = 0; i<nMBSize*MEGA_BYTE;i++)
narrBig[i] = 'A';
cout << "Array contents size: " << narrBig.size()<< " Bytes." <<
endl;
// vector is destroyed at the end of its scope, and its contents are
cleared
}while (nMBSize!=0);
//To have a break before window closes, use:
system("PAUSE");
return 0;
}
Ioannis
* Ioannis Vranos
* Programming pages: http://www.noicys.cjb.net
* Alternative URL: http://run.to/noicys
> -----Original Message-----
> From: dev...@li...
> [mailto:dev...@li...] On Behalf Of staale
> Sent: Friday, May 10, 2002 4:46 AM
> To: jar...@be...; ha...@bl...; Dev-Cpp
> Subject: [DEV-C++] BUG: Dev-C 4.9.20 consolprogram has only
> access to 1MB memory.
>
>
> Se also thread:
> [Dev-C++] not enough memory - how to configure Win2000
> on the mailing list. Test code below
>
> Hi Helmuth,
>
> Turns out this has somthing to do with Dev-C 4.9.20.
>
> This is what I did to verify the problem:
> 1: Tried your file on both w2k (Clean system) or NT4-Sp6. It
> failed on both
> machins.
>
> 2: I installed DEV-C 4.9.20 (downloaded today) on a clean w2k
> machine and
> encountered the same problem when I compiled and ran the code.
>
> 3: Tried to uninstall DEV-C 4.9.20. Uninstal DOES NOT work.
> Delete the fiels
> manualy. Search for dev-c in regedit.exe and then run
> RegClean.exe just
> search for RegClean and you should be well of (Might not nead
> this see pkt
> 5)
>
> 4: Installed DEV-C 4.0 on the w2k machine Compiled and
> tested OK to 31MB.
>
> 5: Installed Dev-c 4.9.20 on top of the 4.0 and It still
> worked nicely..:o)
>
> 6: Installed Dev-C 4.9.20 on NT4-SP6 (Only Winzip appart from
> OS). Added
> shlwapi.dll and wininet.dll to system32 folder. Tried to run
> the code but
> no. Same failure.
>
> 7: Installed Dev-C 4.0 on top of the 4.9.20. This did not
> help. Brobably
> because both installers does not overwrite existing header
> files (?). So you
> should delete the 4.9.x installaation. Install 4.0 and then
> 4.9.x (if you
> nead it. It is a must if you want to use the wxWindows lib,
> if I understand
> right)
>
>
> I'm not a seasoned C developer but would gues there are
> somthing wrong with
> a header file or reference making dev-c 4.9.x compile to
> 16bit code(???)
>
> Best regards
> Staale Flock
>
> ------------------- Code
> Start --------------------------------------------------------
> //////////////////////////////////////////////////////////////
> //////////////
> ///////////////////////////////////////////////////
> // this code fails if you install Dev-C 4.9.20 on a new w2k
> machine and try
> to access
> // more than 1MB memory. (Enter any number higher than 1).
> //////////////////////////////////////////////////////////////
> //////////////
> ///////////////////////////////////////////////////
>
> #include <iostream>
> #include <stdio.h>
> #include <stdlib.h>
>
>
> int main(int argc, char *argv[])
> {
> const long MEGA_BYTE = 1024*1024;
> long nMBSize = 1;
> while (nMBSize != 0 ){
> cout << "Give MB size: ";
> cin >> nMBSize;
> char narrBig[nMBSize * MEGA_BYTE];
> cout << "char size: " << sizeof(char) << " Bytes." << endl;
> cout << "Array size: " << sizeof(narrBig)<< " Bytes." << endl;
> //See if initializing each element makes a difference
> for (unsigned long i = 0; i<nMBSize*MEGA_BYTE;i++){
> narrBig[i] = 'A';
> }//i
> cout << "Array size: " << sizeof(narrBig) << endl;
> //If you store objects in the array remember to use:
> delete []narrBig;
> }//while (nMB..
> //To have a breake before window closes, use:
> system("PAUSE");
> return 0;
> }
>
> ------------------- Code end --------------------------------->
|
|
From: staale <st...@le...> - 2002-05-10 04:52:13
|
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
----- Original Message -----
From: "Ioannis Vranos" <no...@ho...>
To: "Dev-C++ Mailing List" <dev...@li...>
Sent: Friday, May 10, 2002 4:51 AM
Subject: RE: [DEV-C++] BUG: Dev-C 4.9.20 consolprogram has only access to
1MB memory.
> Your code fixed:
>
> #include <iostream>
> file://-->Not needed
> // #include <stdio.h>
> #include <stdlib.h>
>
> file://--> You do not use argc, argv[] so why you declare them?
> int main(int argc, char *argv[])
> {
> using namespace std; // --> necessary
>
> const long MEGA_BYTE = 1024*1024;
>
> long nMBSize = 1;
>
> while (nMBSize != 0 ){
> cout << "Give MB size: ";
> cin >> nMBSize;
>
> file://--> Illegal in ANSI C++. The sizes of arrays in the stack must
be
> constants
> file://--> char narrBig[nMBSize * MEGA_BYTE];
>
> char *narrBig=new char[nMBSize*MEGA_BYTE];
>
>
> file://--> Useless. sizeof(char) is always 1 byte
> file://cout << "char size: " << sizeof(char) << " Bytes." << endl;
>
> file://-->You can't do that on an array on the free store.
> // Here it returns the size of char *
> // cout << "Array size: " << sizeof(narrBig)<< " Bytes." << endl;
> file://See if initializing each element makes a difference
> for (unsigned long i = 0; i<nMBSize*MEGA_BYTE;i++){
> narrBig[i] = 'A';
> }//i
> file://--> Useless. cout << "Array size: " << sizeof(narrBig) << endl;
> file://If you store objects in the array remember to use:
> delete [] narrBig;
> file://--> This could be disastrous when applied on a built in array as
you
> had done
>
>
> }//while (nMB..
> file://To have a breake before window closes, use:
> system("PAUSE");
> return 0;
> }
>
>
> ====
>
>
> How i would do it in your case:
>
>
> #include <iostream>
> #include <cstdlib>
> #include <vector>
>
>
> int main()
> {
> using namespace std;
>
> const unsigned long MEGA_BYTE = 1024*1024;
>
> long nMBSize;
>
> do
> {
> cout << "\nGive MB size: ";
> cin >> nMBSize;
>
> vector<char> narrBig(nMBSize*MEGA_BYTE);
>
> cout << "Array contents size: " << narrBig.size()<< " Bytes." <<
> endl;
>
> for (unsigned long i = 0; i<nMBSize*MEGA_BYTE;i++)
> narrBig[i] = 'A';
>
> cout << "Array contents size: " << narrBig.size()<< " Bytes." <<
> endl;
>
> // vector is destroyed at the end of its scope, and its contents are
> cleared
> }while (nMBSize!=0);
>
> file://To have a break before window closes, use:
> system("PAUSE");
>
> return 0;
> }
>
>
> Ioannis
>
> * Ioannis Vranos
> * Programming pages: http://www.noicys.cjb.net
> * Alternative URL: http://run.to/noicys
>
>
> > -----Original Message-----
> > From: dev...@li...
> > [mailto:dev...@li...] On Behalf Of staale
> > Sent: Friday, May 10, 2002 4:46 AM
> > To: jar...@be...; ha...@bl...; Dev-Cpp
> > Subject: [DEV-C++] BUG: Dev-C 4.9.20 consolprogram has only
> > access to 1MB memory.
> >
> >
> > Se also thread:
> > [Dev-C++] not enough memory - how to configure Win2000
> > on the mailing list. Test code below
> >
> > Hi Helmuth,
> >
> > Turns out this has somthing to do with Dev-C 4.9.20.
> >
> > This is what I did to verify the problem:
> > 1: Tried your file on both w2k (Clean system) or NT4-Sp6. It
> > failed on both
> > machins.
> >
> > 2: I installed DEV-C 4.9.20 (downloaded today) on a clean w2k
> > machine and
> > encountered the same problem when I compiled and ran the code.
> >
> > 3: Tried to uninstall DEV-C 4.9.20. Uninstal DOES NOT work.
> > Delete the fiels
> > manualy. Search for dev-c in regedit.exe and then run
> > RegClean.exe just
> > search for RegClean and you should be well of (Might not nead
> > this see pkt
> > 5)
> >
> > 4: Installed DEV-C 4.0 on the w2k machine Compiled and
> > tested OK to 31MB.
> >
> > 5: Installed Dev-c 4.9.20 on top of the 4.0 and It still
> > worked nicely..:o)
> >
> > 6: Installed Dev-C 4.9.20 on NT4-SP6 (Only Winzip appart from
> > OS). Added
> > shlwapi.dll and wininet.dll to system32 folder. Tried to run
> > the code but
> > no. Same failure.
> >
> > 7: Installed Dev-C 4.0 on top of the 4.9.20. This did not
> > help. Brobably
> > because both installers does not overwrite existing header
> > files (?). So you
> > should delete the 4.9.x installaation. Install 4.0 and then
> > 4.9.x (if you
> > nead it. It is a must if you want to use the wxWindows lib,
> > if I understand
> > right)
> >
> >
> > I'm not a seasoned C developer but would gues there are
> > somthing wrong with
> > a header file or reference making dev-c 4.9.x compile to
> > 16bit code(???)
> >
> > Best regards
> > Staale Flock
> >
> > ------------------- Code
> > Start --------------------------------------------------------
> > //////////////////////////////////////////////////////////////
> > //////////////
> > ///////////////////////////////////////////////////
> > // this code fails if you install Dev-C 4.9.20 on a new w2k
> > machine and try
> > to access
> > // more than 1MB memory. (Enter any number higher than 1).
> > //////////////////////////////////////////////////////////////
> > //////////////
> > ///////////////////////////////////////////////////
> >
> > #include <iostream>
> > #include <stdio.h>
> > #include <stdlib.h>
> >
> >
> > int main(int argc, char *argv[])
> > {
> > const long MEGA_BYTE = 1024*1024;
> > long nMBSize = 1;
> > while (nMBSize != 0 ){
> > cout << "Give MB size: ";
> > cin >> nMBSize;
> > char narrBig[nMBSize * MEGA_BYTE];
> > cout << "char size: " << sizeof(char) << " Bytes." << endl;
> > cout << "Array size: " << sizeof(narrBig)<< " Bytes." << endl;
> > file://See if initializing each element makes a difference
> > for (unsigned long i = 0; i<nMBSize*MEGA_BYTE;i++){
> > narrBig[i] = 'A';
> > }//i
> > cout << "Array size: " << sizeof(narrBig) << endl;
> > file://If you store objects in the array remember to use:
> > delete []narrBig;
> > }//while (nMB..
> > file://To have a breake before window closes, use:
> > system("PAUSE");
> > return 0;
> > }
> >
> > ------------------- Code end --------------------------------->
>
> _______________________________________________________________
>
> Have big pipes? SourceForge.net is looking for download mirrors. We supply
> the hardware. You get the recognition. Email Us: ban...@so...
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|
|
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
|
|
From: <jar...@ig...> - 2002-05-10 06:44:31
|
On 10 May, Ioannis Vranos wrote: > >> -----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. >> > SNIP > > 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. Of course it has. E.g. all the mingw stuff is running nicely and I don't think gcc/g++ will run with such a small stack. Furthermore Staale only wrote a small test for locating the error. My primary failing programm (unfortunately much bigger) doesn't allocate big arrays on the stack. And why does Staale's program run under 4.0 ? Sorry for being harsh, but I have to say so. A C++ system which limits the stack to 0.001 Gb on machines which have 1-4 Gb nowadays is not uptodate. It's my feeling as well, that DevC++ 4.9.x generates 16 bits applications by default. > > Run this code to see the size of your stack: It would be better if there were a method to increase the stack size. It can't believe it's a Win2000 problem. Helmut. -- Helmut Jarausch Lehrstuhl fuer Numerische Mathematik Institute of Technology, RWTH Aachen D 52056 Aachen, Germany |
|
From: Andres R. <lo...@ho...> - 2002-05-10 10:08:41
|
Hi! >>> -----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. >>> >> >SNIP >> >> 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. > >Of course it has. E.g. all the mingw stuff is running nicely and I don't >think gcc/g++ will run with such a small stack. >Furthermore Staale only wrote a small test for locating the error. >My primary failing programm (unfortunately much bigger) doesn't >allocate big arrays on the stack. >And why does Staale's program run under 4.0 ? > >Sorry for being harsh, but I have to say so. >A C++ system which limits the stack to 0.001 Gb on machines >which have 1-4 Gb nowadays is not uptodate. > >It's my feeling as well, that DevC++ 4.9.x generates 16 bits >applications by default. HELLOOO!!! If you are using some wierd old compiler (like renamed borland c/c++ compiler for win3.1 --I don't know how or what--) then you could get 16-bit code. But in reality, Dev-C++ uses MinGW compiler by default, wich generates native Win32 code. > >> >> Run this code to see the size of your stack: > >It would be better if there were a method to increase the >stack size. It can't believe it's a Win2000 problem. > >Helmut. > >-- >Helmut Jarausch > >Lehrstuhl fuer Numerische Mathematik >Institute of Technology, RWTH Aachen >D 52056 Aachen, Germany > > |
|
From: Ioannis V. <no...@ho...> - 2002-05-10 16:09:13
|
> -----Original Message----- > From: jar...@ig... > [mailto:jar...@ig...] > Sent: Friday, May 10, 2002 9:44 AM > To: no...@ho... > Cc: dev...@li... > Subject: Re: [DEV-C++] BUG: Dev-C 4.9.20 consolprogram has > only access to 1MB memory. > > Of course it has. E.g. all the mingw stuff is running nicely > and I don't > think gcc/g++ will run with such a small stack. I did not understand why gcc would not run. > Furthermore Staale only wrote a small test for locating the error. > My primary failing programm (unfortunately much bigger) doesn't > allocate big arrays on the stack. Then what? > And why does Staale's program run under 4.0 ? You mean why it compiled? Because GCC permits more things than ANSI C++ (consider of it as system extensions). All compilers permit more stuff, but for code to be guaranteed to be portable, must be ANSI compliant. > > Sorry for being harsh, but I have to say so. > A C++ system which limits the stack to 0.001 Gb on machines > which have 1-4 Gb nowadays is not uptodate. All compilers have a limit of stack. In DOS times it was 64 K. Now in Windows it is 1-2 MB. With the updated code i sent to the list here is info for thhe stack on my XP system: MINGW: "C:\mingw\bin\g++.exe" -O3 -march=i686 -ansi -pedantic-errors -o temp "temp.cpp": Allocated approximately 2002 KB of stack before i die C:\c> BC++: "bcc32" -6 -O2 "temp.cpp" Allocated approximately 1006 KB of stack before i die C:\c> So as you see MINGW/GCC provides one of the largest stack! > > It's my feeling as well, that DevC++ 4.9.x generates 16 bits > applications by default. No, MINGW produces Win32 applications (even console programs do not run above pure DOS). > > Run this code to see the size of your stack: > > It would be better if there were a method to increase the > stack size. It can't believe it's a Win2000 problem. No it isn't. It is a compiler issue. Ioannis * Ioannis Vranos * Programming pages: http://www.noicys.cjb.net * Alternative URL: http://run.to/noicys |
|
From: staale <st...@le...> - 2002-05-10 07:53:08
|
Hi again Ioannis and Helmut,
Your sample code (yes the application crashes, not the IDE) died (stack
overflow) at Approximately 2002 kB on (Nt4-Sp6 - Dev-C 4.9.20).
On NT4-SP6 Dev-C 4.0 I got 32250 kB before I got a stack overflow error.
The w2k machine with first Dev-C 4.0 and then 4.9.20 installed got the stack
overflow at 2002 kB.
So we could conclude that the two versions of Dev-C (or rather accompanied
compilers) handels stack allocation differently?
Regards
Staale Flock
----- Original Message -----
From: "Ioannis Vranos" <no...@ho...>
To: "Dev-C++ Mailing List" <dev...@li...>
Sent: Friday, May 10, 2002 7:28 AM
Subject: RE: [DEV-C++] BUG: Dev-C 4.9.20 consolprogram has only access to
1MB memory.
>
> > -----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
>
> _______________________________________________________________
>
> Have big pipes? SourceForge.net is looking for download mirrors. We supply
> the hardware. You get the recognition. Email Us: ban...@so...
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|
|
From: Ioannis V. <no...@ho...> - 2002-05-10 16:11:27
|
> -----Original Message----- > From: dev...@li... > [mailto:dev...@li...] On Behalf Of staale > Sent: Friday, May 10, 2002 10:56 AM > To: Dev-C++ Mailing List > Subject: Re: [DEV-C++] BUG: Dev-C 4.9.20 consolprogram has > only access to 1MB memory. > > > Hi again Ioannis and Helmut, > > Your sample code (yes the application crashes, not the IDE) > died (stack > overflow) at Approximately 2002 kB on (Nt4-Sp6 - Dev-C 4.9.20). > > On NT4-SP6 Dev-C 4.0 I got 32250 kB before I got a stack > overflow error. > > The w2k machine with first Dev-C 4.0 and then 4.9.20 > installed got the stack > overflow at 2002 kB. > > So we could conclude that the two versions of Dev-C (or > rather accompanied > compilers) handels stack allocation differently? Probably. Check with the new version of the code that i sent, it should be more accurate. Ioannis * Ioannis Vranos * Programming pages: http://www.noicys.cjb.net * Alternative URL: http://run.to/noicys |
|
From: staale <st...@le...> - 2002-05-10 09:08:35
|
Ioannis and Helmut,
Out of curiosity I tried Ioannis's code in VC6++ SP4 (w2k-machine) , and
KDeveloper 2.0 (RedHat 7.2 - gcc 2.95.x ? ) and the results are:
VC6++ 936 kB
KDeveloper 8064 kB
For fun I tried it in VB and Powerbasic to:
VB6 4382 kB
PB 4309 kB
I'm still puzzeled by the big difference between the two Dev-C releases. The
only logical explenation is that it is posible to configure this somewhere.
Pleace enlighten me..:o)
Regards
Staale Flock
----- Original Message -----
From: "Ioannis Vranos" <no...@ho...>
To: "Dev-C++ Mailing List" <dev...@li...>
Sent: Friday, May 10, 2002 7:28 AM
Subject: RE: [DEV-C++] BUG: Dev-C 4.9.20 consolprogram has only access to
1MB memory.
>
> > -----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
>
> _______________________________________________________________
>
> Have big pipes? SourceForge.net is looking for download mirrors. We supply
> the hardware. You get the recognition. Email Us: ban...@so...
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|
|
From: Ioannis V. <no...@ho...> - 2002-05-10 16:13:27
|
> -----Original Message----- > From: dev...@li... > [mailto:dev...@li...] On Behalf Of staale > Sent: Friday, May 10, 2002 12:12 PM > To: Dev-C++ Mailing List > Subject: Re: [DEV-C++] BUG: Dev-C 4.9.20 consolprogram has > only access to 1MB memory. > > > Ioannis and Helmut, > > Out of curiosity I tried Ioannis's code in VC6++ SP4 > (w2k-machine) , and > KDeveloper 2.0 (RedHat 7.2 - gcc 2.95.x ? ) and the results are: > VC6++ 936 kB > KDeveloper 8064 kB > > For fun I tried it in VB and Powerbasic to: > VB6 4382 kB > PB 4309 kB Basic? How did you run C++ code in BASIC (except if you mean you wrote equivallent recursive BASIC code). > > I'm still puzzeled by the big difference between the two > Dev-C releases. The > only logical explenation is that it is posible to configure > this somewhere. Yes, it is done inside MINGW's source code. :P Ioannis * Ioannis Vranos * Programming pages: http://www.noicys.cjb.net * Alternative URL: http://run.to/noicys |
|
From: staale <st...@le...> - 2002-05-13 06:01:09
|
Well, I'll hold my horses a bit longer before I cry wolf, wolf the next time.:o) As Ioannis has pointed out the different results are differences in the implementation of the mingw32 compiler. Evolving from allowing ca 31MB stack space to ca 2MB. Probably to prevent us from cheating? The following code shows that you have access to all the memory your OS will give you *S*. ------------ Code snip ------------------- // This code consumes memmory on the heap (free storage) // *********************************** // Se also Bruce Eckel 's book Thinking in C++ // page 565 - Running out of storage. // pdf Available at www.BruceEckel.com // *********************************** #include <iostream> int count = 0; int main() { while(true) { count++; // Analyse mem usage with // task manager (NT) or ps, KPM (Linux) int* foo = new int[1024]; // allocate ca 1kB on heap (free storage) if (foo == 0) break; // New return 0 if out of mem (I think!) cout << count << endl; } cout << "new could not allocate more memmory\b" << endl; return 0; } -----------Code end --------------------- Best regards Staale Flock ----- Original Message ----- From: "Ioannis Vranos" <no...@ho...> To: "Dev-C++ Mailing List" <dev...@li...> Sent: Friday, May 10, 2002 6:13 PM Subject: RE: [DEV-C++] BUG: Dev-C 4.9.20 consolprogram has only access to 1MB memory. > > -----Original Message----- > > From: dev...@li... > > [mailto:dev...@li...] On Behalf Of staale > > Sent: Friday, May 10, 2002 12:12 PM > > To: Dev-C++ Mailing List > > Subject: Re: [DEV-C++] BUG: Dev-C 4.9.20 consolprogram has > > only access to 1MB memory. > > > > > > Ioannis and Helmut, > > > > Out of curiosity I tried Ioannis's code in VC6++ SP4 > > (w2k-machine) , and > > KDeveloper 2.0 (RedHat 7.2 - gcc 2.95.x ? ) and the results are: > > VC6++ 936 kB > > KDeveloper 8064 kB > > > > For fun I tried it in VB and Powerbasic to: > > VB6 4382 kB > > PB 4309 kB > > Basic? How did you run C++ code in BASIC (except if you mean you wrote > equivallent recursive BASIC code). > > > > > > I'm still puzzeled by the big difference between the two > > Dev-C releases. The > > only logical explenation is that it is posible to configure > > this somewhere. > > > Yes, it is done inside MINGW's source code. :P > > > > Ioannis > > * Ioannis Vranos > * Programming pages: http://www.noicys.cjb.net > * Alternative URL: http://run.to/noicys > > _______________________________________________________________ > > Have big pipes? SourceForge.net is looking for download mirrors. We supply > the hardware. You get the recognition. Email Us: ban...@so... > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |
|
From: Ioannis V. <no...@ho...> - 2002-05-13 06:22:00
|
Yes, you can access the rest of memory as "free store". Stack is used to
store the execution path of a program and local objects.
Example. Imagine that you have the code:
void k()
{
int x=1;
f();
int y=g(x);
f();
}
int main()
{
int a=5;
f();
int r=g(a);
k();
}
In the stack the following is stored:
a=5;
pointer to f() call. -> // f() things executed here. When it finishes: |
<-----------------------------------------------------------------------
-------
int r;
pointer to g() call--> // g() things executed here. When it finishes: |
<-----------------------------------------------------------------------
--------
r=some_value
pointer to k() call -->
int x=1;
pointer to f() call ---> //finishes |
<-------------------------------------
int y;
pointer to g() call---> // finishes|
<--------------------------------------
y=some_value
pointer to f() call ---> //finishes |
<-------------------------------------
k() finishes. Automatic local objects in
the stack die |
<-----------------------------------------------------------------------
----------------
main() ends.
Automatic local objects in the stack die
return success indicator
I hope it gives some idea.
Ioannis
* Ioannis Vranos
* Programming pages: http://www.noicys.cjb.net
* Alternative URL: http://run.to/noicys
> -----Original Message-----
> From: dev...@li...
> [mailto:dev...@li...] On Behalf Of staale
> Sent: Monday, May 13, 2002 9:05 AM
> To: Dev-C++ Mailing List
> Subject: Re: [DEV-C++] BUG: Dev-C 4.9.20 consolprogram has
> only access to 1MB memory.
>
>
> Well, I'll hold my horses a bit longer before I cry wolf,
> wolf the next
> time.:o)
>
> As Ioannis has pointed out the different results are
> differences in the
> implementation of the mingw32 compiler. Evolving from
> allowing ca 31MB stack
> space to ca 2MB. Probably to prevent us from cheating?
>
> The following code shows that you have access to all the
> memory your OS will
> give you *S*.
|
|
From: Ioannis V. <no...@ho...> - 2002-05-13 06:39:30
|
> -----Original Message----- > From: dev...@li... > [mailto:dev...@li...] On Behalf Of staale > Sent: Monday, May 13, 2002 9:05 AM > To: Dev-C++ Mailing List > Subject: Re: [DEV-C++] BUG: Dev-C 4.9.20 consolprogram has > only access to 1MB memory. > > > Well, I'll hold my horses a bit longer before I cry wolf, > wolf the next > time.:o) > > As Ioannis has pointed out the different results are > differences in the > implementation of the mingw32 compiler. Evolving from > allowing ca 31MB stack > space to ca 2MB. Probably to prevent us from cheating? > > The following code shows that you have access to all the > memory your OS will > give you *S*. > > New return 0 if out of mem (I think!) No, in case of failure new throws by default an std::bad_alloc exception defined in <new>. It doesn't return 0. Ioannis * Ioannis Vranos * Programming pages: http://www.noicys.cjb.net * Alternative URL: http://run.to/noicys |
|
From: Ioannis V. <no...@ho...> - 2002-05-10 16:00:30
|
I had written the stack size counting program in asleep mode, that's why
it had logical errors. The correct one:
#include <iostream>
void stack()
{
using namespace std;
static unsigned long counter=0;
char buffer[1024-sizeof(void *)];
counter++;
cout<<"Allocated approximately "<<counter;
cout<<" KB of stack before i die\n";
stack();
}
int main()
{
stack();
}
|
|
From: Ioannis V. <no...@ho...> - 2002-05-10 16:32:03
|
This is the final stack counting ANSI C++ compliant code with the
maximum precision i can make. Sorry for the many postings:
#include <iostream>
void stack()
{
using namespace std;
// Variable is created on the stack permanently and
// keeps its value between stack() calls (a nightmare
// for concurrency).
static unsigned long counter=0;
// sizeof(void *) to remove the size of the pointer the function call
// occupies itself on the stack
char buffer[1024-sizeof(void *)];
counter++;
// -sizeof(counter) to remove the size of the static variable
// counter. -sizeof(void *) to remove the size of the pointer of
main()
// in the stack.
cout<<"Allocated approximately "<<counter-sizeof(counter)-sizeof(void
*);
cout<<" KB of stack before i die\n";
stack();
}
int main()
{
stack();
}
Ioannis
* Ioannis Vranos
* Programming pages: http://www.noicys.cjb.net
* Alternative URL: http://run.to/noicys
|