more than 256 Mbyte?

Mike Corbeil mcorbeil@netrevolution.com
Mon Jul 10 06:15:00 GMT 2000


"Martin v. Loewis" wrote:

> > Here is what happens when I run test.cc:
>
> This is likely not a compiler bug. Try running the following C program
>
> int main()
> {
>   char *p=malloc(0x10000000);
>   if(p)
>     printf("PASS\n");
>   else
>     printf("FAIL\n");
> }
>
> If it fails, you simply cannot allocate 256M on your machine; then
> there is nothing the compiler can do about it.

If the machine has this much or more for memory, and the OS is Unix or
Linux, then what about increasing ulimit (or limit, depending on which
Unix shell is being used) to allow access to the amount of memory
needed?  This once worked for an Ada compiler and system I worked on.
The compiler kept choking up, we contacted the compiler vendor, its staff
replied with the answer being to merely increase the value of ulimit, and
this allowed the compilation to succeed.

I don't know if there's anything similar or analogous on non-Unix OSs.

In some cases, it would probably be necessary to not allocate or allow so
much memory for a user, however this may possibly vary depending on the
application or system and user, as well as how much memory is needed.  If
too much memory is needed to allow a single user to grab it all at once,
then maybe the program logic can be written such that less memory needs
to be allocated per any one particular step.

Also, even if the OS is a Unix and ulimit can be increased to allow a
user to grab all of the available memory, then ulimit may not be a good
solution, if portability is an issue.  In this case, it would possibly be
wise to ensure portability from the start and then code the logic of the
program accordingly.


mike


>
>
> Regards,
> Martin



More information about the Gcc-help mailing list