return NULL if there is no more memory available. Try, for example, simple loops like:
x = malloc(10000); for (i=0; x != NULL; i++) { x = malloc(10000); if (x == NULL) printf("x is NULL\n"); }
My application terminates with a segmentation violation, but all attempts to handle this by signal() or atexit() fail. Unfortunately, also sysconf() does not work to get the number of available pages (_SC_AVPHYS_PAGES, I get always the same but wrong value).
While testing, I detected that errno is set to 12 ("Not enough memory") after enough iterations through the for-loop above, while variable x still is not zero. But still my application crashes even when I break the loop at errno!=0.
Is there any secure way to find out, how much memory is available (or hope that the malloc() problems will be solved)?
Many thanks, Juergen
-- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/