Out of memory error

G

Guest

Hi all !

I have a problem. I need to use two huge variables (square matrices), 500
MBytes each. My memory is 3GB RAM and 3GB swap. 300M of them occupied by
system.

Memory for the first one allocates well, without problems. But when program
tries to allocate memory for second matrix, "Out of memory" error occurs.
But there is a great amount of free memory !!!

Can you tell me, what is the reason and how I can fix it. Is there any
VisualC 7.0 tuning, connected with memory allocation ? It's acceptably to
storage variables in the swap. Is there any compiler directive, which
specify, that variable can be moved into the swap ?

I didn't find answers in the MSDN disk documentation. May be, someone know
the title of the Articles, connected with these questions.

Thank you, and sorry for my English :)
 
B

Bo Persson

Anatoly said:
Hi all !

I have a problem. I need to use two huge variables (square
matrices), 500
MBytes each. My memory is 3GB RAM and 3GB swap. 300M of them
occupied by
system.

Memory for the first one allocates well, without problems. But when
program
tries to allocate memory for second matrix, "Out of memory" error
occurs.
But there is a great amount of free memory !!!

Can you tell me, what is the reason and how I can fix it. Is there
any
VisualC 7.0 tuning, connected with memory allocation ? It's
acceptably to
storage variables in the swap. Is there any compiler directive,
which
specify, that variable can be moved into the swap ?

I didn't find answers in the MSDN disk documentation. May be,
someone know
the title of the Articles, connected with these questions.

Thank you, and sorry for my English :)

It's not a matter of how much memory space you have, but how
fragmented it is. Usually, the user address space is 2 GB (with the
other 2GBG reserved to the system). This doesn't mean that you can
allocate one 2 GB element, but that the sum of all your allocated
memory can approach 2 GB.

After you have allocated the first 500 MB element, there may very well
be enough space available to allocate 5 * 100 MB, but perhaps not a
single 500 MB element. When entering a parking lot, there might easily
be places for 5 cars, but perhaps not one single space for 5 cars.

Do you really (really!) need to have the elements allocated in such
big pieces, or can you possibly split them up in several smaller
parts?



Bo Persson
 
G

Guest

Bo Persson said:
It's not a matter of how much memory space you have, but how
fragmented it is. Usually, the user address space is 2 GB (with the
other 2GBG reserved to the system). This doesn't mean that you can
allocate one 2 GB element, but that the sum of all your allocated
memory can approach 2 GB.

After you have allocated the first 500 MB element, there may very well
be enough space available to allocate 5 * 100 MB, but perhaps not a
single 500 MB element. When entering a parking lot, there might easily
be places for 5 cars, but perhaps not one single space for 5 cars.
Bo Persson

Thank you.
The problem in the time - in future the program will be optimized and
matrices will be much smaller, but now we need to solve some tasks quickly.

Do you know, how can I order the compiler to allocate memory as compactly,
as possible, witout "holes" ?
 
B

Bob Milton

Anatoly,
You're best bet is to have your program allocate the two 500MB arrays on
the heap when it first starts. There is less likely to be any memory
fragmentation when you first start. You will, of course, have to pass
pointers to this allocated memory to the routines that need them, but that
is a small price to pay.
Bob Milton
 
G

Guest

Hi,

Assuming that you really need a random access array so big, try to
get a Windows Server system that supports 3 GB for user mode (/3GB boot
switch)
or a system that supports PAE.
In the latter case you'll need to use special AWE API to allocate the memory
and manage the mapping window (it is not a true random access)

--PA
 

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

Top