Size of array too large

D

danieleghisi

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
 
I

Ian Collins

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?
Use dynamic allocation (malloc).

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

A. Sinan Unur

(e-mail address removed) wrote in
@k37g2000hsf.googlegroups.co
m:
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?

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
 
R

Richard Tobin

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

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
 
I

Ian Collins

Chris said:
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];

You have a syntax error here.
Where?
 
D

danieleghisi

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];

You have a syntax error here.

[...]

Yap, sure... It was a typo, i didn't copy-paste! :p

Thanks everybody for the answers... It's hard to find another way for
the algorithm, so i'll try to follow your advices.
My mac has 2GB of Ram, but I just bought 2 additional Gb :p
 
I

Ian Collins

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];
You have a syntax error here.

[...]

Yap, sure... It was a typo, i didn't copy-paste! :p

Thanks everybody for the answers... It's hard to find another way for
the algorithm, so i'll try to follow your advices.
My mac has 2GB of Ram, but I just bought 2 additional Gb :p

You'll probably still run out!
 
B

Bartc

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];
Thanks everybody for the answers... It's hard to find another way for
the algorithm, so i'll try to follow your advices.
My mac has 2GB of Ram, but I just bought 2 additional Gb :p

If your /compiler/ is reporting the memory problem, extra ram might not
help.
 
I

Ian Collins

Bartc said:
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];
Thanks everybody for the answers... It's hard to find another way for
the algorithm, so i'll try to follow your advices.
My mac has 2GB of Ram, but I just bought 2 additional Gb :p

If your /compiler/ is reporting the memory problem, extra ram might not
help.
it was barfing in the size of a static array. Dynamic allocation is a
different kettle of fish.
 
H

Harry Skelton

Ian said:
it was barfing in the size of a static array. Dynamic allocation is a
different kettle of fish.

....and you could always do disk cached array, if you lack memory. Just
build it as a class that fetches the record involved.
 
K

Kenny McCormack

...and you could always do disk cached array, if you lack memory. Just
build it as a class that fetches the record involved.

You are not allowed to use the "c-word" (cl*ss) in this NG (clc).
 
H

Harry Skelton

Kenny said:
You are not allowed to use the "c-word" (cl*ss) in this NG (clc).

...Fine...what do the youth of today say? "My Bad"?...

char * GetBigArrayItem(int ItemToCall) {
/* code to read the ItemToCall record from disk and return it */
/* as a string pointer */
/* I figure you can figure out how to write it to disk with */
/* a single call.... */
}

(...Lord I feel old. It's been years since I have had to write flat
code - as opposed to object oriented, or real C for that matter...)

#insert <grins/sheepish.h>
#Const MORON TRUE
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,007
Latest member
obedient dusk

Latest Threads

Top