473,587 Members | 2,492 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Out of memory with 2-dimensional float/double matrix

Hello,

I´m using a very large 2-dimensional double matrix (45.000x45.000)
in my program.

At the initialization of the matrix:

double[,] matrix = new double[45000,45000] I am getting an out of memory
error.

The program is running on a Windows 2003 Server with 8 GB Ram
and 20 GB virtual Ram.

So I thought this must be enough.
If I am sure, a double value uses 8 Byte.
So the matrix must be 45000*45000*8By te = 15.087 GB.

Is this right?

My first question is now... must a matrix in C# fit in the Main Memory
(8 GB) or are party of the matrix automatically copied to the virtual
Memory if the matrix is too large?

In other words... can I handle a matrix which takes more than 8 GB Ram?

I also tried to use float instead of double but I am getting the same error.

Is there something smaller than a float which I could use?
I need 4 signs behind the comma.
I am logged in as normal user at the Windows 2003 Server.
Do I maybe have some virtual resource restrictions?
It is a "standard-installation".

I would be happy if somebody has an idea how to go on bugtracking my
problem.
Regards,

Martin
Dec 16 '06 #1
21 4634
Martin,

you didn't state whether your C# application is 32-bit or 64-bit, but if it
is 32-bit (which is the default, one could say), then you are trying to do
something that is not possible in 32-bit applications.

That is, each 32-bit application can only address 2^32 = 4 gigabytes of
virtual address space, of which at least one gigabyte (1 GB, by default 2
GB) is reserved to the operating system. It doesn't matter how much memory
in total your server has, you can't allocate more than 2 or 3 GB of memory
in a single application. See here:

http://msdn2.microsoft.com/en-gb/library/aa366912.aspx

If your application is a 64-bit one, then your memory allocation should
succeed given that the server has enough free memory and you've specified
your application as being "large address aware". If you are in the 32-bit
world, then there's no other option than to divide your array into smaller
parts, or use for instance a file/database to store the data.

Hope this helps.

--
Regards,

Mr. Jani Järvinen
C# MVP
Helsinki, Finland
ja***@removethi s.dystopia.fi
http://www.saunalahti.fi/janij/
Dec 16 '06 #2
Hello Jani,

thank you very much for your help.
you didn't state whether your C# application is 32-bit or 64-bit, but if it
is 32-bit (which is the default, one could say), then you are trying to do
something that is not possible in 32-bit applications.
Can you tell me how to check this?

The server has 4xIntel Xeon 3.4 Ghz CPUs and the Operation System is
Windows 2003 Enterprise with SP 1.0

I´ve read that Xeon is a 32-Bit CPU but there are versions with the
EM64T Extension.

How can I check if my CPU has a EM64T Extension or not?

And what about the Win2003 Enterprise OS.
How can I check if it is a 64Bit Version of Win2003 or not?
Regards,
Martin
Dec 16 '06 #3
"Jani Järvinen [MVP]" <ja***@removeth is.dystopia.fiw rote in message
news:Om******** ******@TK2MSFTN GP06.phx.gbl...
Martin,

you didn't state whether your C# application is 32-bit or 64-bit, but if it is 32-bit
(which is the default, one could say), then you are trying to do something that is not
possible in 32-bit applications.

That is, each 32-bit application can only address 2^32 = 4 gigabytes of virtual address
space, of which at least one gigabyte (1 GB, by default 2 GB) is reserved to the operating
system. It doesn't matter how much memory in total your server has, you can't allocate
more than 2 or 3 GB of memory in a single application. See here:

http://msdn2.microsoft.com/en-gb/library/aa366912.aspx

If your application is a 64-bit one, then your memory allocation should succeed given that
the server has enough free memory and you've specified your application as being "large
address aware". If you are in the 32-bit world, then there's no other option than to
divide your array into smaller parts, or use for instance a file/database to store the
data.

Nope, even on 64 bit this application will fail, the maximum size of an object is limited to
2GB in all current versions of the CLR. Sure you can allocate 8 array's of 2GB each on 64
bit, but not a single array of 16GB.

Willy.

Dec 16 '06 #4
On Sat, 16 Dec 2006 12:13:11 +0100, Martin Pöpping
<ma******@despa mmed.comwrote:
>Hello,

I´m using a very large 2-dimensional double matrix (45.000x45.000)
in my program.

At the initialization of the matrix:

double[,] matrix = new double[45000,45000] I am getting an out of memory
error.

The program is running on a Windows 2003 Server with 8 GB Ram
and 20 GB virtual Ram.

So I thought this must be enough.
If I am sure, a double value uses 8 Byte.
So the matrix must be 45000*45000*8By te = 15.087 GB.

Is this right?

My first question is now... must a matrix in C# fit in the Main Memory
(8 GB) or are party of the matrix automatically copied to the virtual
Memory if the matrix is too large?

In other words... can I handle a matrix which takes more than 8 GB Ram?

I also tried to use float instead of double but I am getting the same error.

Is there something smaller than a float which I could use?
I need 4 signs behind the comma.
I am logged in as normal user at the Windows 2003 Server.
Do I maybe have some virtual resource restrictions?
It is a "standard-installation".

I would be happy if somebody has an idea how to go on bugtracking my
problem.
Regards,

Martin
How many of the positions in your array are non-zero? You might be
able to save memory by using a sparse matrix representation.

Do you need random access to the array or can you process it serially?
Serial processing might allow you to keep it in a file rather than in
memory and just retrieve it one row at a time.

You could use a database to store the numbers, 16GB is not large for a
database. Just retrieve the numbers you need from the database as
required.

rossum

Dec 16 '06 #5
Martin,

I'm just curious. Why do you need a matrix that big? Maybe I or
someone else can offer other options.

Brian

Dec 16 '06 #6
Brian Gideon schrieb:
I'm just curious. Why do you need a matrix that big? Maybe I or
someone else can offer other options.
Hi Brian,

I´m doing a document "pre-clustering" with a graphical algorithm
(connected components).

That´s why I need a comparison of each document to each other.

If I have 45.000 documents f.e. I need a 45.000x45.000 document matrix.

I know that I can compress the size of the matrix by using an
upper triangle matrix, but after my calculations this would also do not
fit to my memory space.

So I really have to devide my matrix into several smaller matrixes.
Regards,

Martin
Dec 17 '06 #7

Martin Pöpping wrote:
Brian Gideon schrieb:
I'm just curious. Why do you need a matrix that big? Maybe I or
someone else can offer other options.

Hi Brian,

I´m doing a document "pre-clustering" with a graphical algorithm
(connected components).

That´s why I need a comparison of each document to each other.

If I have 45.000 documents f.e. I need a 45.000x45.000 document matrix.
Or you need some other structure that stores, for each document, its
relationship to every other document. Is there a reason that you need
the entire thing in memory all at once? Could you use some form of
indexed file to store the relationships? What kinds of operations are
you doing with the matrix elements, and how many operations do you need
to do? Is there some sort of performance requirement?

If all you need to do is store the results of comparing every document
with every other document, then I would think that a file would be a
better structure, given the amount of data you're talking about. If, on
the other hand, you need to perform complex traversals over the data
over and over again, you need things to be in memory.

Dec 17 '06 #8
Hi Martin,
there are also other ways you can go about figurung out which labels are
equivalent in your connected component algorithm, one would be to have a
single array of 45,000 items where each array elemnt is a linked list
containing all of the other labels that are equivalent, after the first pass
of your data you can then choose one label for each item in your list and do
a second pass through your data to rename the labels. I have done this a few
times when I have used this algorithm in image processing and it works very
well and is very fast. Just some other ideas instead of trying to build a
matrix of all possible combinations.

Mark.
--
http://www.markdawson.org
"Martin Pöpping" wrote:
Brian Gideon schrieb:
I'm just curious. Why do you need a matrix that big? Maybe I or
someone else can offer other options.

Hi Brian,

I´m doing a document "pre-clustering" with a graphical algorithm
(connected components).

That´s why I need a comparison of each document to each other.

If I have 45.000 documents f.e. I need a 45.000x45.000 document matrix.

I know that I can compress the size of the matrix by using an
upper triangle matrix, but after my calculations this would also do not
fit to my memory space.

So I really have to devide my matrix into several smaller matrixes.
Regards,

Martin
Dec 17 '06 #9
Martin Pöpping <ma******@despa mmed.comwrote:
>I´m doing a document "pre-clustering" with a graphical algorithm
(connected components).
That´s why I need a comparison of each document to each other.
If I have 45.000 documents f.e. I need a 45.000x45.000 document matrix.
(sorry I've only been to a couple of lectures on the topic and don't
really know the field) but this seems like the time where you start
reading up on algorithms and datastructures for solving the problem,
not the time to look up on language support for features.

What algorithm are you using? Your matrix seems O(n^2) but a random
glance through google gives me the impression that people are using
O(n.log n) or O(n) for their specialized clustering problems. One page
I saw reckoned they could cluster 100.000 documents of 10 variables in
under 50 minutes. And they say that an n^2 matrix would have taken
40gb but they did it in only 40mb.
http://www.clustan.com/clustering_large_datasets.html

--
Lucian
Dec 17 '06 #10

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

Similar topics

0
2037
by: Andreas Suurkuusk | last post by:
Hi, I just noticed your post in the "C# memory problem: no end for our problem?" thread. In the post you implied that I do not how the garbage collector works and that I mislead people. Since the thread is over a month old, I decided to start a new one with my response. Please see my comments inline.
4
13001
by: Frank Esser | last post by:
I am using SQL 8 Personal edition with sp2 applied. I set the max server memory to 32MB and leave the min server memory at 0. When my application starts hitting the database hard the memory usage reported through task manager peaks between 41-42MB. I've stopped and restarted the MSSQLserver service and checked that the running values are...
4
2583
by: Franklin Lee | last post by:
Hi All, I use new to allocate some memory,even I doesn't use delete to release them. When my Application exit, OS will release them. Am I right? If I'm right, how about Thread especally on Solaries OS? This means that I use new to allocate memory in one Thread and doesn't use delete to release them.
9
2341
by: Mike P | last post by:
I know everything about reference counting and making sure you don't have large objects lying around. I have also profiled my app with multiple tools. I know about the fact GC collects memory but not necessary give it back to the OS. It seems that .NET win app will only return memory to the OS when the OS is asking for it. But!!! When...
22
3462
by: xixi | last post by:
hi, we are using db2 udb v8.1 for windows, i have changed the buffer pool size to accommadate better performance, say size 200000, if i have multiple connection to the same database from application server, will each connection take the memory 800M (200000 x 4k = 800 M), so the memory took will be 800M times number of connections, or the...
14
20758
by: Alessandro Monopoli | last post by:
Hi all, I'm searching a PORTABLE way to get the available and total physical memory. Something like "getTotalMemory" and it returns the memory installed on my PC in bytes, and "getAvailableMemory" and it returns the available memory in bytes. Do you know is there's a C function, a c++ Object or anything else that compiles in Linux and...
1
3008
by: Nick Craig-Wood | last post by:
I've been dumping a database in a python code format (for use with Python on S60 mobile phone actually) and I've noticed that it uses absolutely tons of memory as compared to how much the data structure actually needs once it is loaded in memory. The programs below create a file (z.py) with a data structure in which looks like this --...
5
24653
by: kumarmdb2 | last post by:
Hi guys, For last few days we are getting out of private memory error. We have a development environment. We tried to figure out the problem but we believe that it might be related to the OS (I am new to Windows so not sure). We are currently bouncing the instance to overcome this error. This generally happen at the end of business day...
1
2032
by: Jean-Paul Calderone | last post by:
On Tue, 22 Apr 2008 14:54:37 -0700 (PDT), yzghan@gmail.com wrote: The test doesn't demonstrate any leaks. It does demonstrate that memory usage can remain at or near peak memory usage even after the objects for which that memory was allocated are no longer live in the process. This is only a leak if peak memory goes up again each time you...
5
505
by: cham | last post by:
Hi, I am working on c++ in a linux system ( Fedora core 4 ), kernel version - 2.6.11-1.1369_FC4 gcc version - 4.0.0 20050519 ( Red Hat 4.0.0-8 ) In my code i am creating a vector to store pointers of type structure "SAMPLE_TABLE_STRUCT" ( size of this structure is 36 bytes ). I create an instance of structure "SAMPLE_TABLE_STRUCT" using...
0
7920
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7849
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8215
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8347
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
5718
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3844
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2358
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1454
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1189
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.