How do I force a program to appear to run out of memory?
问题 I have a C/C++ program that might be hanging when it runs out of memory. We discovered this by running many copies at the same time. I want to debug the program without completely destroying performance on the development machine. Is there a way to limit the memory available so that a new or malloc will return a NULL pointer after, say, 500K of memory has been requested? 回答1: Try turning the question on its head and asking how to limit the amount of memory an OS will allow your process to use