数组的大小太大 [英] Size of array too large

查看:99
本文介绍了数组的大小太大的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好


我正在写一个小程序来寻找一些特定的整数集

(同音集),以及每一组是一个未签名的长期

(例如{1,2,4,7} --1001011 = 75)。我需要一个很长的

这类套装清单,所以我宣布了一个


#define MAXS = 397148160

static unsigned long long set [MAXS];


但MAXS对我的编译器来说似乎有点太大了(我正在使用Xcode

on一个Mac Book Pro,2.5GHz),它返回一个数组大小太大

错误。


有没有办法解决这个问题很长一段时间

unsigned long long?


非常感谢

Daniele Ghisi

Hello

I''m writing a small programme to look for some particular integer sets
(homometric sets), and each one of this sets is a unsigned long long
(e.g. {1, 2, 4, 7} --1001011=75). I need to have a very long list of
sets of this kind, so I declared a

#define MAXS = 397148160
static unsigned long long set[MAXS];

but MAXS seems to be a bit too large for my compiler (I''m using Xcode
on a Mac Book Pro, 2.5GHz), that returns a "size of array too large"
error.

Is there a way to solve this problem and have a very long array of
unsigned long long?

Thank you very much
Daniele Ghisi

推荐答案

da ********* *@gmail.com 写道:

你好


我正在编写一个小程序来查看对于某些特定的整数集

(同音集),并且这些集合中的每一个都是无符号长长的

(例如{1,2,4,7} - 1001011 = 75)。我需要一个很长的

这类套装清单,所以我宣布了一个


#define MAXS = 397148160

static unsigned long long set [MAXS];


但MAXS对我的编译器来说似乎有点太大了(我正在使用Xcode

on一个Mac Book Pro,2.5GHz),它返回一个数组大小太大

错误。


有没有办法解决这个问题并且有一长串

unsigned long long?
Hello

I''m writing a small programme to look for some particular integer sets
(homometric sets), and each one of this sets is a unsigned long long
(e.g. {1, 2, 4, 7} --1001011=75). I need to have a very long list of
sets of this kind, so I declared a

#define MAXS = 397148160
static unsigned long long set[MAXS];

but MAXS seems to be a bit too large for my compiler (I''m using Xcode
on a Mac Book Pro, 2.5GHz), that returns a "size of array too large"
error.

Is there a way to solve this problem and have a very long array of
unsigned long long?



使用动态分配(malloc)。


你的阵列将是巨大的,超过3GB,所以你最好有足够的内存!


-

Ian Collins。

Use dynamic allocation (malloc).

Your array will be huge, over 3GB, so you better have plenty of RAM!

--
Ian Collins.


da**********@gmail.com 写在

news:945ff496-791e-44b5-90c9-6fed76ffc5e8

@ k37g2000hsf.googlegroups.co

m:
da**********@gmail.com wrote in
news:945ff496-791e-44b5-90c9-6fed76ffc5e8
@k37g2000hsf.googlegroups.co
m:

你好


我正在写一个小专业人士用来寻找一些特定的整数

集(同音集),这些集合中的每一个都是无符号长的

长(例如{1,2,4,7} --1001011 = 75)。我需要一个

很长的这类套装清单,所以我宣布了一个


#define MAXS = 397148160

static unsigned long long set [MAXS];


但MAXS对于我的编译器来说似乎有点太大了(我正在使用

Xcode on一个Mac Book Pro,2.5GHz),它返回一个大小的数组

太大。错误。


有没有办法解决这个问题并且有一个很长的数组

unsigned long long?
Hello

I''m writing a small programme to look for some particular integer
sets (homometric sets), and each one of this sets is a unsigned
long long (e.g. {1, 2, 4, 7} --1001011=75). I need to have a
very long list of sets of this kind, so I declared a

#define MAXS = 397148160
static unsigned long long set[MAXS];

but MAXS seems to be a bit too large for my compiler (I''m using
Xcode on a Mac Book Pro, 2.5GHz), that returns a "size of array
too large" error.

Is there a way to solve this problem and have a very long array of
unsigned long long?



我假设long long是64位。所以,如果我的算术是正确的,

我们正在谈论这个数组的大约3 Gb内存。


我认为是时候重新考虑算法。


思南


-

A. Sinan Unur< 1u ** @ llenroc.ude .invalid>

(删除.invalid并反转每个组件的电子邮件地址)

I am assuming long long is 64 bits. So, if my arithmetic is correct,
we are talking about approx 3 Gb memory just for this array.

Methinks it''s time to rethink the algorithm.

Sinan

--
A. Sinan Unur <1u**@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)


在文章< 94 ******* ********* @ k37g2000hsf。 googlegroups.com>,

< da ********** @ gmail.comwrote:
In article <94**********************************@k37g2000hsf. googlegroups.com>,
<da**********@gmail.comwrote:

># define MAXS = 397148160
static unsigned long long set [MAXS];
>#define MAXS = 397148160
static unsigned long long set[MAXS];



如果long long是64位(它在你的Mac上),这需要超过

3GB的内存。如果你在32位模式下编译,这比系统可以处理的
更大。 (32位指针的地址空间是4GB,

但我认为你在Mac上不能超过2GB。)使用malloc()

代替没有帮助。


它*应*用于构建它作为64位程序 - 也就是说,一个

使用64位指针。 Mac上的标志是-m64。但是,

它似乎仍然无法处理它:显然大小为bss的大小。 region存储为32位数字。如果你使用malloc()

内存而不是它应该使用-m64。


- Richard

-

:wq

If long long is 64 bits (which it is on your Mac), this requires over
3GB of memory. If you compile in 32-bit mode, this is bigger than
the system can handle. (The address space for 32-bit pointers is 4GB,
but I think you can''t have more than 2GB on the Mac.) Using malloc()
instead won''t help.

It *should* work to build it as a 64-bit program - that is, one that
uses 64-bit pointers. The flag for this on the Mac is -m64. However,
it still doesn''t seem to be able to handle it: apparently the size of
the "bss" region is stored as a 32-bit number. If you malloc() the
memory instead it should work with -m64.

-- Richard
--
:wq


这篇关于数组的大小太大的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆