lkml.org 
[lkml]   [2004]   [Dec]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: 2.6.9, 64bit, 4GB memory => panics ...
On Sun, 5 Dec 2004, Rudolf Usselmann wrote:

> int mem[10000];
> int i, n;
>
> for(i=0;i<2000;i++) {
> printf("Doing alloc %0d ...\n",i);
> mem[i] = (int)malloc(1024*1024*1024);

allocate a 1 gig block, but store it in an int array? That's wrong.

> if(mem[i] == NULL)
> printf("Malloc failed ...\n");
> else
> for(n=0;n<(1024*1024*1024);n=n+640) mem[i] = n;

You alter n, but then always only set mem[i], without varying i.

Your program is buggy, and memleaks.

Plus, the kernel uses overcommit by default, and since you aren't actually
touching the memory you are allocating, you are only limited by the address
space size allowed per process(depends on how you configured the kernel).

-
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/

\
 
 \ /
  Last update: 2005-03-22 14:08    [W:0.036 / U:0.256 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site