Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How much RAM C# application can use? [closed]

Tags:

c#

memory

I have application with very big DataTable objects, very big arrays etc.

Currently my memory usage is below 2GB.

What will happen when my application produce 4 arrays with 1GB size on 32 bit system?

Will it crash?

I know about 2GB object size limit in CLR, but what about many big objects?

I tried to just test it, I declared few big arrays, but when they are empty they seems to not use RAM. I didn't tried to fill them, i decided to just ask here.

like image 449
Kamil Avatar asked Dec 21 '22 06:12

Kamil


2 Answers

64 bit application, including managed ones, can access large memory.

32 bit application have a virtual address space of maximum 4GB. In practaice they get 2GB by default. /LARGEADRESSAWARE applicaitons can get 3GB with /3gb in boot.ini or 4GB when running on WoW64.

Managed application, even on x64 cannot allocate any single object larger than 2GB. Including arrays.

But no matter the amount of VA available at your disposal: manipulating a +2GB DataTable object is just not going to work. Use a storage engine capable of handling and manipulating large amounts of data fast, and capable of intelligent paging. Redis, Cassandra or even traditional RDBMSs are more suited for the job.

Even if you decide to manipulate the data directly in memory, you need a smarter format than DataTable.

like image 141
Remus Rusanu Avatar answered Feb 22 '23 09:02

Remus Rusanu


All 32bit applications are limited to 2GB of memory*. So no matter how you divvy the RAM up you'll run out at 2GB.

If you need more you'll need to run it on a 64bit system and compile it for 64bit.

  • Using LARGEADDRESSAWARE 32bit applications can use up to 3GB of memory, thanks Marc Gravell for reminding me of this in the comments.
like image 41
Frazell Thomas Avatar answered Feb 22 '23 09:02

Frazell Thomas