473,326 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

largest array possible

i have created a 7-dimensional array [11,11,11,11,11,11,11] which has 19.5
million elements.

when i try to create 8-dimensional array i get out of bounds system
exception. does anyone know if this limitation is due to amount of memory
in my pc or a limiation of c# language?

thanks
Nov 15 '05 #1
9 2253
> when i try to create 8-dimensional array i get out of bounds system
exception. does anyone know if this limitation is due to amount of memory
in my pc or a limiation of c# language?


write it to a file...
--
H.Schampheleer
hu****@haps.be
www.haps.be
Nov 15 '05 #2
Hi tony,

I don't think that .net has such limitations.
I would say that it is a memory issue.

--
Miha Markic - RightHand .NET consulting & software development
miha at rthand com

"tony collier" <me*****@hotmail.com> wrote in message
news:Xn*************************@194.117.133.134.. .
i have created a 7-dimensional array [11,11,11,11,11,11,11] which has 19.5
million elements.

when i try to create 8-dimensional array i get out of bounds system
exception. does anyone know if this limitation is due to amount of memory
in my pc or a limiation of c# language?

thanks

Nov 15 '05 #3
Actually, I would guess there is a limit because of the limitation of
the Length propery. In the 1.0 version of the framework, the Length
property was a 32 bit integer, and because of that, you were limited to two
billion or so elements.

With the 1.1 version of the framework, you have the LongLength property,
which exposes the length in a 64 bit integer, which means you have an upper
limit of 9,223,372,036,854,775,808 elements (needless to say, a lot).

However, what you are running into, like Miha said, is probably because
of a memory constraint. To the original poster, do you really need to have
that many elements in the array? What are you trying to do? Depending on
the type of your elements, the memory alone for such an array could be
restrictive in terms of performance.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Miha Markic" <miha at rthand com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi tony,

I don't think that .net has such limitations.
I would say that it is a memory issue.

--
Miha Markic - RightHand .NET consulting & software development
miha at rthand com

"tony collier" <me*****@hotmail.com> wrote in message
news:Xn*************************@194.117.133.134.. .
i have created a 7-dimensional array [11,11,11,11,11,11,11] which has 19.5 million elements.

when i try to create 8-dimensional array i get out of bounds system
exception. does anyone know if this limitation is due to amount of memory in my pc or a limiation of c# language?

thanks


Nov 15 '05 #4
Sure, but it returns "Length" cast to a long, so the max. value is still 2
Billion elements.

Willy.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:et**************@tk2msftngp13.phx.gbl...
Actually, I would guess there is a limit because of the limitation of
the Length propery. In the 1.0 version of the framework, the Length
property was a 32 bit integer, and because of that, you were limited to two billion or so elements.

With the 1.1 version of the framework, you have the LongLength property, which exposes the length in a 64 bit integer, which means you have an upper limit of 9,223,372,036,854,775,808 elements (needless to say, a lot).

However, what you are running into, like Miha said, is probably because of a memory constraint. To the original poster, do you really need to have that many elements in the array? What are you trying to do? Depending on
the type of your elements, the memory alone for such an array could be
restrictive in terms of performance.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Miha Markic" <miha at rthand com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi tony,

I don't think that .net has such limitations.
I would say that it is a memory issue.

--
Miha Markic - RightHand .NET consulting & software development
miha at rthand com

"tony collier" <me*****@hotmail.com> wrote in message
news:Xn*************************@194.117.133.134.. .
i have created a 7-dimensional array [11,11,11,11,11,11,11] which has 19.5 million elements.

when i try to create 8-dimensional array i get out of bounds system
exception. does anyone know if this limitation is due to amount of memory in my pc or a limiation of c# language?

thanks



Nov 15 '05 #5

"Willy Denoyette [MVP]" <wi*************@pandora.be> wrote in message
news:OU**************@TK2MSFTNGP11.phx.gbl...
Sure, but it returns "Length" cast to a long, so the max. value is still 2
Billion elements.


Yes, I am waiting for 128bit procesor so that I can put enough memory into
my computer ;-)

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com
Nov 15 '05 #6
I have created 9 dimensional arrays similar to that without any problems. (I
used very dynamic jagged arrays.) I use this in a production environment and
it is absolutely reliable. It does take a good bit of memory, but the code
executes really fast and works really well. So I say, "Go for it!" if you
really need this. If your dimensions are all hard coded, as they appear to
be, you can probably find a better alternative, however.

This looks like a situation where some good data structures-type design work
could really pay off. If you care to share more details, I'll provide more
comments.

If you do move forward with the 7 dimen array, and if you are using it in
code you plan to keep, put a lot of thought into making it OO and
maintainable. If the array is as dynamic as ours, someone coming along after
you won't be able to figure the code out unless it is very nicely designed.
I wouldn't manipulate a 7 dimensional array directly in other code -- put it
behind properties or methods.

BTW, you can have 2 billion elements in each dimension.

"tony collier" <me*****@hotmail.com> wrote in message
news:Xn*************************@194.117.133.134.. .
i have created a 7-dimensional array [11,11,11,11,11,11,11] which has 19.5
million elements.

when i try to create 8-dimensional array i get out of bounds system
exception. does anyone know if this limitation is due to amount of memory
in my pc or a limiation of c# language?

thanks

Nov 15 '05 #7
ok . thanks everyone for your advice so far. sorry to post several times
the same message - i am getting used to my newsreader software.

This is what i am trying to
do and there is probably a much better way which this newbie hasn't read
or thought about yet.

i am getting prices from x number of suppliers who all quote me a
different individual price for each of y items. no one supplier is always
cheaper than the others.

no. of suppliers: x (preferably unlimited)

no. of items: y (again, preferably unlimited)

i then calculate all the different combination of items from mixed
suppliers. The formula to work out number of combinations =

no.of supplier ^ (to the power of) no. of items.

this requires creating an array of y dimensions with x elements per
dimension to store all combinations

as you will now understand , i have so far only been able to go up to x=
11, and y=7 before running into memory constraints.

items must be able to be added/deleted like in a cart until user
checksout, so no running calculation can take place to try and crunch
numbers as i go. this is why i can't see how array can be made any
smaller.

hope this all makes sense. any ideas to do this in a better way would be
greatly appreciated.
Incidentally, is there any way to initalize all elements in the array to
zero in one fell swoop rather than looping through them? Someone has
mentioned .system.array.clear - does this work on uninitialized elements?
someone else said that this was a feature not carried over from c++.

Also, someone asked about some suppliers not having all items. So far i
have covered this with another y=7,x=11 array where elements get flagged
for any corresponding combination element that is zero.

A database was mentioned although i know very very little about ado.net
and sql so this would be a real chore for me to do it this way - surely
reading and writing would be too slow for so many entries anyway?

regards TC.
Nov 15 '05 #8
tony collier wrote:
A database was mentioned although i know very very little about
ado.net and sql so this would be a real chore for me to do it this
way - surely reading and writing would be too slow for so many
entries anyway?


There's two ways to solve a problem: the fast way and the right way. If
you want to code an application that will not require any code
maintenance when the number of suppliers and/or items change, ADO.NET is
the way to go.

--
There are 10 kinds of people. Those who understand binary and those who
don't.

http://code.acadx.com
(Pull the pin to reply)
Nov 15 '05 #9
the suppliers will be fixed but the items will change on EVERY query as
they are searched for and then selected from an enormous list (which i
don't have access to) by clients thru a webform and and i can't get the
price for the items until i know what the client wants. I then
automatically go to the suppliers for prices and return the bestprice
combination to the user. For this reason i can't pre-populate a database.
I guess I could start with an empty database that populates with a client
request and then deletes entries once client closes session rather than
letting database grow and grow unneccesarily. Does this sound like a
better way than working with arrays?
Nov 15 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Nicholas | last post by:
How can I get the largest possible value of the Integer Constants and use it in the program for these types: 1. int 2. long 3. unsigned short Thanks
13
by: Peter Ammon | last post by:
I have a floating point number. I'd like to get the nearest floating point number that is larger or smaller than the given number. I investigated FLT_EPSILON but it only seems to be useful if the...
20
by: Rajesh | last post by:
Hello Everybody, Can anybody help me to write a C program for finding the second largest element in an array. without using any sort algo. The array may conatin duplicate elements. The algo...
19
by: ramu | last post by:
Hi, I have, suppose 1000 numbers, in a file. I have to find out 5 largest numbers among them without sorting. Can you please give me an efficient idea to do this? My idea is to put those numbers...
3
by: HEMH6 | last post by:
Who can help solve this problem??? Finding the Largest Value (a) write a function, largest(), that returns the largest value in a signed integer array. The array and its size are passed as...
9
by: tom | last post by:
Hi! How can I determine the smallest and largest values of numeric types (for example int) possible in my system? I think there exists a function for this task but I don't know it.
38
by: bele_harshad2006 | last post by:
how can i pick up largest no from 5 rows by 5 column matrix????
5
by: akselo | last post by:
Hello folks, I have a function where I pass numbers from a table, and I want to compare them and return the largest horizontal value. I store them in an array, and try the DMAX function on it, but...
8
by: MLH | last post by:
Is there any built-in FN for returning largest value in a group of say 2 - 10 values? Lets say I want a FN something like MaxVal(5, 7, 9, 3, 12) or perhaps MaxVal(79,34). I would wanna see return...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.