473,394 Members | 1,715 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,394 software developers and data experts.

Out of memory error

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 :-)
Nov 17 '05 #1
4 1267

"Anatoly" <An*****@discussions.microsoft.com> skrev i meddelandet
news:FF**********************************@microsof t.com...
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
Nov 17 '05 #2
"Bo Persson" wrote:
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" ?
Nov 17 '05 #3
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

"Anatoly" <An*****@discussions.microsoft.com> wrote in message
news:28**********************************@microsof t.com...
"Bo Persson" wrote:
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" ?

Nov 17 '05 #4
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

"Anatoly" wrote:
"Bo Persson" wrote:
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" ?

Nov 17 '05 #5

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

Similar topics

0
by: Srijit Kumar Bhadra | last post by:
Hello, Here is some sample code with pywin32 build 203 and ctypes 0.9.6. Best regards, /Srijit File: SharedMemCreate_Mutex_win32all.py # This application should be used with...
1
by: Attila.Rajmund.Nohl | last post by:
Hello! I'm using KAI C++ Compiler (KCC) Version 4.0d on Sparc Solaris 8 with Sun WorkShop 6 update 2 backend (KCC compiles C++ code to C than uses the Sun compiler to produce machine...
6
by: Andrzej | last post by:
Used to read newsgroup for answers, now have to ask for them as well. I have an application (C#, .NET 1.1) that connects to local db on MSDE 2000 SP3a (using ADO from MDAC 2.71) on one side and...
25
by: Zeng | last post by:
I finally narrowed down my code to this situation, quite a few (not all) of my CMyClass objects got hold up after each run of this function via the simple webpage that shows NumberEd editbox. My...
4
by: Sean Shanny | last post by:
To all, Running into an out of memory error on our data warehouse server. This occurs only with our data from the 'September' section of a large fact table. The exact same query running over...
2
by: saran | last post by:
I am having a problem with MySQL consuming a lot of memory and eventually throwing an Out of Memory error and restarting itself. The symptoms are that swap usage continues to rise until some...
6
by: tgnelson85 | last post by:
Hello, C question here (running on Linux, though there should be no platform specific code). After reading through a few examples, and following one in a book, for linked lists i thought i would...
5
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...
27
by: George2 | last post by:
Hello everyone, Should I delete memory pointed by pointer a if there is bad_alloc when allocating memory in memory pointed by pointer b? I am not sure whether there will be memory leak if I do...
2
by: ravishi | last post by:
Well, this is my first topic at this forum and I'm a newbie on C programming too. I'm coding a little program and I've used some "dynamic arrays" on it. Compiling and running the program on Linux...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
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,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.