From: Brian Budge <brian.budge@gmail.com>
To: Anna Sidera <sidera.anan@ucy.ac.cy>
Cc: gcc-help@gcc.gnu.org
Subject: Re: maximum array size?
Date: Thu, 15 Apr 2010 12:43:00 -0000 [thread overview]
Message-ID: <q2u5b7094581004150217j3b6b646ega13e3bc574444fb9@mail.gmail.com> (raw)
In-Reply-To: <q2u5b7094581004150136ub04edd05j68a7a7677d537507@mail.gmail.com>
Oh, you said that there is a lot of *unused* memory... sorry, I
misread. This is almost certainly a bug in your program. You should
compile with -g and run the program in gdb to see where the program
crashes.
Brian
On Thu, Apr 15, 2010 at 1:36 AM, Brian Budge <brian.budge@gmail.com> wrote:
> Is this running in Linux? Linux usually behaves optimistically,
> actually returning a valid pointer from malloc, even when there is not
> enough memory left in the system to satisfy the request. A good
> explanation can be found here:
> http://linuxdevcenter.com/pub/a/linux/2006/11/30/linux-out-of-memory.html
>
> On Thu, Apr 15, 2010 at 1:26 AM, Anna Sidera <sidera.anan@ucy.ac.cy> wrote:
>> Hello,
>>
>> I wrote a program in gcc. I compile it with the option -m64. Is there a limit in how much memory malloc can allocate? I run the program for different values of some input parameters. The program defines some scalar variables and arrays. Then it defines a large array and tries to set a value in an element of the array.
>> int **bufferc = malloc((inp_par_a*inp_par_b+2)*sizeof(int *));
>> int *bufferc_aux = malloc((inp_par_a*inp_par_b+2)*(inp_par_c+1)*sizeof(int));
>> int bfc=1;
>> bufferc[bfc]=bufferc_aux+bfc*(inp_par_c+1);
>> bufferc[bfc][0]=0;
>> At this point sometimes there is no problem but sometimes I get segmentation fault. There is a lot of unused ram in the server when the problem occurs. Do you think the problem is due to a bug that I have before defining the array?
>>
>> Thanks,
>> Anna
>>
>
next prev parent reply other threads:[~2010-04-15 9:17 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-15 9:17 Anna Sidera
2010-04-15 10:17 ` Brian Budge
2010-04-15 12:43 ` Brian Budge [this message]
2010-04-15 15:31 ` John S. Fine
[not found] ` <f61380541765a.4bc757a9@ucy.ac.cy>
2010-04-15 16:00 ` John S. Fine
2010-04-16 13:48 ` Anna Sidera
2010-04-16 13:51 ` Anna Sidera
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=q2u5b7094581004150217j3b6b646ega13e3bc574444fb9@mail.gmail.com \
--to=brian.budge@gmail.com \
--cc=gcc-help@gcc.gnu.org \
--cc=sidera.anan@ucy.ac.cy \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).