From: Rudolf Usselmann <rudi@asics.ws>
To: Adam Heath <doogie@debian.org>
Cc: Linux Kernel <linux-kernel@vger.kernel.org>
Subject: Re: 2.6.9, 64bit, 4GB memory => panics ...
Date: Sun, 05 Dec 2004 14:32:43 +0700 [thread overview]
Message-ID: <1102231963.3780.88.camel@cpu0> (raw)
In-Reply-To: <Pine.LNX.4.58.0412050118230.2173@gradall.private.brainfood.com>
On Sun, 2004-12-05 at 14:20, Adam Heath wrote:
> 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).
Thanks for pointing that out Adam ! Will this work better:
#include "stdio.h"
#include "stdlib.h"
int main() {
char *mem[10000];
int i, n;
for(i=0;i<2000;i++) {
printf("Doing alloc %0d ...\n",i);
mem[i] = (char *)malloc(1024*1024*1024);
if(mem[i] == NULL)
printf("Malloc failed ...\n");
else
for(n=0;n<(1024*1024*1024);n=n+640) mem[i][n] = n;
}
while(1);
return(0);
}
Thanks !
rudi
next prev parent reply other threads:[~2004-12-05 7:33 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-12-03 11:20 2.6.9, 64bit, 4GB memory => panics Rudolf Usselmann
2004-12-03 11:37 ` William Lee Irwin III
2004-12-03 12:15 ` Rudolf Usselmann
2004-12-05 5:39 ` Rudolf Usselmann
2004-12-05 6:26 ` Zwane Mwaikambo
2004-12-05 7:03 ` Rudolf Usselmann
2004-12-05 7:20 ` Adam Heath
2004-12-05 7:32 ` Rudolf Usselmann [this message]
2004-12-05 7:29 ` Zwane Mwaikambo
2004-12-05 7:44 ` Rudolf Usselmann
2004-12-05 7:53 ` William Lee Irwin III
2004-12-05 8:50 ` Rudolf Usselmann
2004-12-05 7:28 ` Rudolf Usselmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1102231963.3780.88.camel@cpu0 \
--to=rudi@asics.ws \
--cc=doogie@debian.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.