Re: maximum array size?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx> 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@xxxxxxxxx> 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
>>
>


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux