This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: Cygwin Maximum Memory Documentation
- From: Rob Donovan <hikerman2005-542731 at yahoo dot com>
- To: Jay K <jay dot krell at cornell dot edu>
- Cc: cygwin <cygwin at cygwin dot com>
- Date: Wed, 28 Apr 2010 11:49:53 -0700
- Subject: Re: Cygwin Maximum Memory Documentation
- References: <1272411106.9772.ezmlm@cygwin.com> <COL101-W2442C3EC902156FF38B193E6030@phx.gbl>
Looks like I posted too soon.
I can run SOME Cygwin/gcc programs up to 2.83GB with the changes I mentioned in my first post (yesterday), but not ALL programs (and not anything useful...). The problem seems to be with Cygwin's implementation of disk access functions like fscanf() and fgets(). The following code as written here and compiled under gcc/Cygwin (with the gcc line commented out at the top) WILL run up to 2.83GB image size. However, if the fscanf() line is uncommented the resulting program dies just above a 2GB image size with the error "*** fatal error - cmalloc would have returned NULL". The file tmp contains "hello.\n". If the program is compiled with fscanf() uncommented using cl (Visual Studio C++ compiler - the 2nd compile line commented out below) the program will run up to 2.83GB before it runs out of memory. fgets() has the same effect as fscanf(). I'm using Task Manager Mem Usage column to watch the memory grow.
I also tested fprintf(stdout,...) strlen() sscanf() calloc() sprintf() fopen() fabs() fclose() strtok() strcmp() strdup() strspn() and free() all of which work fine up to 2.83GB.
My conclusion is that there's something in Cygwin's implementation of disk access functions (fscanf(), fgets(), ...?) that stops working when the process image size goes over 2GB. Since the /3GB switch enables user pointers above 7FFFFFFF my guess would be something like assumptions made about the most significant pointer bit.
/rob
#include <stdlib.h>
#include <stdio.h>
// to compile : gcc -g -Wall -Wpadded -Wl,--large-address-aware -o memory_eater2.x memory_eater2.c
// to compile : cl memory_eater2.c winmm.lib /link /largeaddressaware
int main (int argc, char *argv[])
{
FILE *f;
char *buf;
long c = 0;
while (1 != 2) {
if ((buf = (char *) calloc(24,sizeof(char))) == NULL) {
fprintf(stderr,"Problem in %s line %d allocating memory\n",__FILE__,__LINE__);
return(1);
}
c++;
if ((c % 5000) == 0) {
if ((f = fopen("./tmp","r")) == NULL) {
fprintf(stderr,"Problem in %s line %d opening input file\n",__FILE__,__LINE__);
return(1);
}
// fscanf(f,"%s",buf);
fclose(f);
}
}
return(0);
}
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple