From: Tung-Han Hsieh <thhsieh@xcin.phys.ntu.edu.tw>
To: linux-kernel@vger.kernel.org
Cc: jamagallon@able.es
Subject: malloc problem to allocate very large blocks
Date: Mon, 28 Jul 2003 14:44:28 +0800 [thread overview]
Message-ID: <20030728064428.GA32138@xcin> (raw)
Hello,
I am developing applications which requires more than 2GB memory.
But I found that in my Linux system the malloc() cannot allocate
more than 2GB memory. Here is the details of my system:
CPU: Pentium 4 2.53 GHz
RAM: 2 GB
Swap: 512 MB
OS: Debian-3.0 stable
Kernel: 2.4.20
gcc: 2.95.4 20011002
glibc: 2.2.5-6
In theory, in a 32-bits machine the maximum allocatable memory
is up to 4GB. But in the following very simple testing program:
=====================================================================
#include <stdio.h>
#include <stdlib.h>
main()
{
size_t l;
char *s1=NULL, *s2=NULL;
l = 1024*1024*1024;
s1 = malloc(l);
s2 = malloc(l);
if (! s1) printf("s1 malloc failed\n");
if (! s2) printf("s2 malloc failed\n");
}
=====================================================================
only the block for s1 can be allocated. Further, if I change the
program to
=====================================================================
#include <stdio.h>
#include <stdlib.h>
main()
{
size_t l;
char *s1=NULL;
l = 2*1024*1024*1024;
s1 = malloc(l);
if (! s1) printf("s1 malloc failed\n");
}
=====================================================================
the gcc complier complain to me that "foo.c:9: warning: integer overflow
in expression" during the compilation (I use: "gcc foo.c" to compile it),
and the block for s1 cannot be allocated at all. I am wondering if there
is any way to overcome the 2GB limit.
Thank you very much for your reply in advance.
Best Regards,
T.H.Hsieh
next reply other threads:[~2003-07-28 6:29 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-07-28 6:44 Tung-Han Hsieh [this message]
2003-07-28 8:37 ` malloc problem to allocate very large blocks jw schultz
2003-07-28 9:14 ` jw schultz
2003-07-29 4:58 ` Nagendra Singh Tomar
2003-07-29 5:02 ` Nagendra Singh Tomar
2003-07-29 11:52 ` Alan Cox
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=20030728064428.GA32138@xcin \
--to=thhsieh@xcin.phys.ntu.edu.tw \
--cc=jamagallon@able.es \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox