From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25136 invoked by alias); 15 Apr 2010 15:31:03 -0000 Received: (qmail 25126 invoked by uid 22791); 15 Apr 2010 15:31:03 -0000 X-SWARE-Spam-Status: Yes, hits=5.8 required=5.0 tests=BAYES_50,BOTNET,RCVD_IN_DNSWL_NONE,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from vms173013pub.verizon.net (HELO vms173013pub.verizon.net) (206.46.173.13) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 15 Apr 2010 15:30:53 +0000 Received: from [10.10.1.168] ([unknown] [209.190.166.162]) by vms173013.mailsrvcs.net (Sun Java(tm) System Messaging Server 7u2-7.02 32bit (built Apr 16 2009)) with ESMTPA id <0L0X00LFCCK3J3C6@vms173013.mailsrvcs.net> for gcc-help@gcc.gnu.org; Thu, 15 Apr 2010 10:33:39 -0500 (CDT) Message-id: <4BC73113.8060908@verizon.net> Date: Thu, 15 Apr 2010 16:00:00 -0000 From: "John S. Fine" User-Agent: Thunderbird 2.0.0.24 (Windows/20100228) MIME-version: 1.0 To: Anna Sidera , GCC Help Mailing List Subject: Re: maximum array size? References: <4BC709D3.7000206@verizon.net> In-reply-to: Content-type: text/plain; charset=ISO-8859-1; format=flowed Content-transfer-encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2010-04/txt/msg00155.txt.bz2 Integers in x86_64 are 32 bit. So in your chain of multiplying you need to multiply by something of type std::size_t before the running value goes over two billion. As it is now, you get overflow in the integer multiply so the case that seems to work is actually reserving far less memory than you think you are requesting. Once you get rid of the integer overflow, you should see that the amount you can reserve is limited by swap size plus large part of ram, so if you really want something that big, you'll need a lot more swap space. Anna Sidera wrote: > inp_par_a=10000 and inp_par_b=10000. For inp_par_c=60 the program works. For inp_par_c=40 or inp_par_c=80 I get segmentation fault. > > I just calculated the memory the array needs and it is more than the available 10GB ram + 3GB swap in the system even for inp_par_c=40. > > > > >