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: 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
>
|