On Saturday 23 July 2005 00:43, John Pearson wrote: > Wouldn't having (practically) all your memory used for cache slow down > starting a new program? First it would have to free up that space, and then > put stuff in that space, taking potentially twice as long. I think there > should be a system call for freeing cached memory, for those that do want to > do it.
I think this one is good enough: #include <stdlib.h> int main() { void *p; unsigned size = 1<<20; unsigned long total=0; while(size) { p = malloc(size); if(!p) size>>=1; else { memset(p, 0x77, size); total+=size; printf("Allocated %9u bytes, %12lu total\n",size,total); } } return 0; } You may want to adapt it so that it takes an argument now many megabytes to eat before it dies. -- vda - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/