Is there a way to get ulimit-style virtual memory limit enforcement on 64-bit Cygwin processes?
I'm a programmer and occasionally I have a bug that sends a process into a memory-grabbing tail-spin. On 32-bit Cygwin, such a runaway process gets stopped cold at 4GB VM (and usually crashes), but 4GB is well short of the physical memory on my 64-bit windows system so this doesn't affect my system stability. However a similar runaway process on 64-bit Cygwin is easily capable of grabbing nearly all of the memory on my system, which can lead to Very Bad Things - ie unrelated user processes start crashing, desktop window manager disappears, and the system slows to a crawl or freezes entirely - making it difficult or impossible to kill the run-away. Several times now I've had to hard power-cycle to recover from such a Cygwin-64 runaway memory-grabbing process, and have lost some data as a result. You can replicate this behavior with a very simple program: (however I DON'T recommend running this) #include <stdlib.h> #include <stdio.h> int main() { printf("WARNING: I'm stealing all your memory, hit control-c to cancel!!!\n");fflush(0); while(1) malloc(1e6); return 0; } The traditional POSIX solution to this problem is setrlimit() aka bash ulimit, but that does not appear to be implemented in Cygwin 2.7.0: $ ulimit -a core file size (blocks, -c) unlimited data seg size (kbytes, -d) unlimited file size (blocks, -f) unlimited open files (-n) 256 pipe size (512 bytes, -p) 8 stack size (kbytes, -s) 2036 cpu time (seconds, -t) unlimited max user processes (-u) 256 virtual memory (kbytes, -v) unlimited $ ulimit -v 1048576 bash: ulimit: virtual memory: cannot modify limit: Invalid argument Is there any hidden setting or other way to enforce a reasonable VM / heap memory / page commit limit on 64-bit Cygwin processes (or even all windows processes) via some other mechanism? I'm running Windows 7 Pro. I've searched the Cygwin mailing list archives, user guide, FAQ, and Google and not found a suitable answer. I've tried the peflags utility mentioned in the Cygwin user guide, but that doesn't seem capable of doing what I need, even for a single executable (although ideally I want to enforce a system-wide limit). Thanks for your consideration. -Dan Bonachea -- 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