1

I know that there's a 2 GiB limitation on all objects in .NET (either in x86 or x64 architecture) and due to memory fragmentation and .NET overhead, you can use up to 1.2-1.4 GB of your application virtual memory before you get OutOfMemory Exception. So when I do:

 int[] array1 = new int[300 * 1000 * 1000];//about 1.1 GB

for 32-bit application on 64-bit OS, I get OutOfMemory Exception which is predictable. but when compiled to 64-bit, the CLR is able to allocate memory on heap and no runtime errors occurs.

What happens that CLR is able to find contiguous block of memory when the application is compiled to x64 that it cannot do for x86 platform target?

Thanks.

user3723486
  • 189
  • 1
  • 3
  • 12
  • You should also consider the page file. – Paul Zahra Sep 12 '16 at 12:13
  • You're looking at VERY old information from 8 years ago, that information is outdated since you're most likely using a way newer version of .NET Framework. – Timo Salomäki Sep 12 '16 at 12:14
  • consider the page file? can you explain more? – user3723486 Sep 12 '16 at 12:16
  • Have a read of http://stackoverflow.com/questions/934314/maximum-memory-a-net-process-can-allocate?rq=1 – Paul Zahra Sep 12 '16 at 12:20
  • @paulzahra thanks, but the page file is the same for both x86/x64 build.I still cannot find the info I was looking for. – user3723486 Sep 12 '16 at 13:00
  • I'm not sure what answer you're looking for that isn't already mentioned in the question. Memory fragmentation is far less of an issue with a 64-bit address space. – Damien_The_Unbeliever Sep 12 '16 at 13:14
  • 1
    @Damien_The_Unbeliever, _Memory fragmentation is far less of an issue with a 64-bit address space_ .what do you mean by that? do you mean that CLR is able to find contiguous block of memory in 64-bit user-mode address space that it cannot in 32-bit address space? – user3723486 Sep 12 '16 at 13:20
  • 2
    [Virtual Address Space](https://msdn.microsoft.com/en-us/library/windows/desktop/aa384271(v=vs.85).aspx): "By default, 64-bit Microsoft Windows-based applications have a user-mode address space of 8 terabytes". Contrast that with 2 (or 3) GB for a 32-bit system. You're searching for space for a 1.1GB object somewhere within an address space that's ~8000 times larger than the object, rather than (32-bit) being ~0.9 times larger. – Damien_The_Unbeliever Sep 12 '16 at 13:23

0 Answers0