Messages in this thread | | | Date | Sun, 5 Dec 2004 00:29:35 -0700 (MST) | From | Zwane Mwaikambo <> | Subject | Re: 2.6.9, 64bit, 4GB memory => panics ... |
| |
On Sun, 5 Dec 2004, Rudolf Usselmann wrote:
> // -------------------------- eat mem --------------------------------- > > #include "stdio.h" > #include "stdlib.h" > > int main() { > > int mem[10000];
Array of integers, you probably want int *mem[10000] if anything.
> int i, n; > > for(i=0;i<2000;i++) { > printf("Doing alloc %0d ...\n",i); > mem[i] = (int)malloc(1024*1024*1024);
Wrongly assigning pointer to signed integer, casting can sometimes be evil.
> if(mem[i] == NULL) > printf("Malloc failed ...\n"); > else > for(n=0;n<(1024*1024*1024);n=n+640) mem[i] = n;
You lose the pointer value here and do not touch the allocated memory, which means that the VM isn't forced to commit the memory you allocated. You also want to be looking at the Committed_AS and Mapped fields of /proc/meminfo
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |