473,785 Members | 3,245 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to use a huge memory in C#?

My system has 4GB memory and My program in C# is really memory
consuming. and I noticed that when the memory I used is more than 2GB I
will get an exception.

How to solve this? thanks a lot

Oct 10 '06
13 5459

"fAnSKyer/C# newbie" <fa******@gmail .comwrote in message
news:11******** *************@i 42g2000cwa.goog legroups.com...
| Thanks a lot for give me great help.
| I will try the /3GB to see if it solve the problem
|
| But I am quite curious that a 32-bit can search a 4GB memory, why the
| bottleneck is 2GB?
|
| This is not a bug, but I am wonder if I can do it better because I
| write 2 memory consuming thread in one program. I may separate them to
| two program and using .NET remoting to control these two to solve this?
|

You won't solve anything, first because remoting is not meant to 'share'
memory space, second you will introduce something real bad that is "paging".
The reason is simple, you have 4GB of physical memory in your system, great
but this 4GB isn't available to the OS because some part of it is 'stolen'
by the HW to map things like motherborad and adapter BIOS and more
importantly graphics adapter memory.
So let's pretend you keep 3.5 GB available to the SW, this has to be shared
between all running processes and the OS. Say you have two processes that
each try to commit 2GB of memory, that make 4GB and add to this the other
processes comitted memory space (more precisely their working sets), but you
simply don't have the physical memory available you and you will find
yourself in a painfull world of heavy paging.
The only solution is to move to a 64 bit environment, that is 64 bit HW, 64
bit OS and MORE than 4GB of RAM installed. But may I ask you again, why do
you need this huge amount of memory, what kind of application is this?

Willy.

Oct 11 '06 #11

"Chris Mullins" <cm******@yahoo .comwrote in message
news:OB******** ******@TK2MSFTN GP02.phx.gbl...
| Sure enough. A quick Google Search agrees with you.
|
| I wonder if the last time I tried was v1.0? I don't think it's been that
| long.
|
Could be, but it could be something else....

| I do remember at that time (we were doing extensive profiling), we wanted
to
| host our Server using the Server CLR, not the Workstation CLR. I needed to
| write a C++ hosting exe to do this. If I remember right, that means it
must
| have been 1.0, since in 1.1 CLR selection was a config file entry.
|
Keep in mind that the /4GT RAM tuning introduces another serious issue, that
is OS resource exhaustion, most of the time it doesn't solve anything, this
trick was invented by MSFT specifically to give MSQL and Exchange some more
headroom.
Also, keep i mind is that this extra GB is separated from the lower 2GB by
the loaded modules (DLL's) and an additional 64KB gap. That means that you
don't get a contigious memory block of 3GB to allocate, so if you think you
can now create a 2GB byte array, you will soon find out that you can't.
Fragmentation bytes again ;-)

| Ah well. I'm probably just confused. We've been 64-bit for a while now, so
| this just doesn't come up for me anymore. Anytime a customer asks "how big
| can it scale?" we just give out the 64-bit numbers.

Absolutely right, whenever your application needs more than 2GB, move to 64
bit.

Willy.

Oct 11 '06 #12
Thanks for your really helpful advice.
the program is a speech search engine and really memory consuming, But
I think I can optimize it to decrese the useage of memory.
using remote may work because it used about 1.5GB memory, so plus it is
3.0GB : )

However, I got in some problems

1) I try to use /3GB but it doesn't work, I modified my boot.ini file
as follows
multi(0)disk(0) rdisk(0)partiti on(1)\WINDOWS=" Windows Server 2003,
Standard" /noexecute=optou t /fastdetect /3GB

2) if there is anyway to upgrade the system to 64bit? I am not sure if
a 32bit CPU gan run a 64bit System
Thanks a lot

Willy Denoyette [MVP] wrote:
"fAnSKyer/C# newbie" <fa******@gmail .comwrote in message
news:11******** *************@i 42g2000cwa.goog legroups.com...
| Thanks a lot for give me great help.
| I will try the /3GB to see if it solve the problem
|
| But I am quite curious that a 32-bit can search a 4GB memory, why the
| bottleneck is 2GB?
|
| This is not a bug, but I am wonder if I can do it better because I
| write 2 memory consuming thread in one program. I may separate them to
| two program and using .NET remoting to control these two to solve this?
|

You won't solve anything, first because remoting is not meant to 'share'
memory space, second you will introduce something real bad that is "paging".
The reason is simple, you have 4GB of physical memory in your system, great
but this 4GB isn't available to the OS because some part of it is 'stolen'
by the HW to map things like motherborad and adapter BIOS and more
importantly graphics adapter memory.
So let's pretend you keep 3.5 GB available to the SW, this has to be shared
between all running processes and the OS. Say you have two processes that
each try to commit 2GB of memory, that make 4GB and add to this the other
processes comitted memory space (more precisely their working sets), but you
simply don't have the physical memory available you and you will find
yourself in a painfull world of heavy paging.
The only solution is to move to a 64 bit environment, that is 64 bit HW, 64
bit OS and MORE than 4GB of RAM installed. But may I ask you again, why do
you need this huge amount of memory, what kind of application is this?

Willy.
Oct 12 '06 #13

"fAnSKyer/C# newbie" <fa******@gmail .comwrote in message
news:11******** ************@i4 2g2000cwa.googl egroups.com...
| Thanks for your really helpful advice.
| the program is a speech search engine and really memory consuming, But
| I think I can optimize it to decrese the useage of memory.
| using remote may work because it used about 1.5GB memory, so plus it is
| 3.0GB : )
|

This is a rather simplistic assumption, you forget the OS memory
requirements, neither do I see how you could split your memory needs over
two processes.

| However, I got in some problems
|
| 1) I try to use /3GB but it doesn't work, I modified my boot.ini file
| as follows
| multi(0)disk(0) rdisk(0)partiti on(1)\WINDOWS=" Windows Server 2003,
| Standard" /noexecute=optou t /fastdetect /3GB

This is not the only requirement, you also have to enable your program to be
"largeaddressaw are", see one of my previous answers.
But again this is not going to help you if your requirement is to get a
larger free block of memory, all you get is an extra block, but if you try
to allocate a large array of say >1.5 GB it will fail even with /3GB and
largeaware enabled.
Honestly, you need to redesign or switch to 64 bit.
|
| 2) if there is anyway to upgrade the system to 64bit? I am not sure if
| a 32bit CPU gan run a 64bit System
|
Nope, you need 64 bit hardware and OS.

Willy.
Oct 12 '06 #14

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

Similar topics

8
1603
by: Pat | last post by:
I am using VC++ 6.0 to develop my program. class A { Object *obj public: A() { obj=new Object ; } ; }
7
2083
by: Vasil Buraliev | last post by:
Hallo. I started a solution in VS.NET with template for C# windwos application. The solution has several projects: -Artifacts -BusinessRules -Client -ErrorLog -Standardization .... ... ..
12
8674
by: Tony | last post by:
Hi expert, I installed DB2 v8.2 server on Solaris 9 box. When I connect to DB2 using control centre or other applications(except command line), around 12 db2sysc processes pop up and each one consumes more than 2G memory(total 30G memory). The server only has 8G physical memory, so DB2 costs too many memory resources. I tried to reduce the appgroup_mem_sz and app_ctl_heap_sz, but it didn't work. What else can I do?
26
1716
by: sam_cit | last post by:
Hi Everyone, I'm in a need to allocate huge memory block of size 50kb. How can i use malloc() for this purpose, asuming sizeof(int) is two bytes? Thanks in advance!!!
0
10325
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10148
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10091
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9950
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7499
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4053
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
2
3646
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2879
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.