Carsten Breuer wrote: > Hi all, > Hi! > after finding out, that malloc come back with NULL > even on linux (where people says here, it don't),
It does, but it's a tricky topic. Please post your test program! I've tried this one on Ubuntu 9.10 in VirtualBox: #include <stdio.h> #include <malloc.h> #include <string.h> void main() { int sz = 16*1024*1024; while (sz > 0) { printf("%d: ", sz); void *p = malloc(sz); if (p != NULL) { // Touch the memory !!! // (observe the effect of commenting it out!) // memset(p, 0x55, sz); printf("ok!\n"); } else { printf("failed.\n"); sz >>= 1; } } printf("still alive!\n"); } $ gcc eatmem.c -o eatmem $ ./eatmem 16777216: ok! 16777216: ok! [ .. ~30 times, takes 2 minutes with heavy thrashing] 16777216: ok! 16777216: ok! 16777216: ok! 16777216: ok! 16777216: ok! Killed Please note that without the memset, no thrashing or killing will occur. The program will terminate with "still alive!". That's because linux has virtual memory, and can overcommit. Real memory pages are only allocated on first _use_. _______________________________________________ Openocd-development mailing list Openocd-development@lists.berlios.de https://lists.berlios.de/mailman/listinfo/openocd-development