I take over a C# project which loads 3D models into memory, so I need large memory to use. My platform is 64-bit win10, the C# program is 32-bit, and I use visual studio 2013 to develop. My laptop have 8GB memory.
Before I use editbin /largeaddressaware $(TargetPath)
to add LARGE_ADDRESS_AWARE flag to the C# program, it could only consume memory approximately 1GB then program throws OutOfMemory exception, after adding LARGE_ADDRESS_AWARE flag, it could consume memory approximately 1.5GB.
I know that using LARGE_ADDRESS_AWARE on 32-bit process running on 64-bit platform, the memory limit is 4GB. I have also read some articles, says because .NET back-end work and memory fragment, the process is not able to really allocate memory to 4GB.
But I think 1.5GB is way too far to 4GB, so I want to ask is there any other factor will cause memory usage limit? Thank you for your answer.
Asked
Active
Viewed 318 times
1

Shan-Hung Hsu
- 127
- 2
- 14
-
3.NET limits object size to max 2 GB even on 64 bit platforms. https://stackoverflow.com/questions/4312169/net-object-size-limit – Mitch Wheat Apr 03 '18 at 01:30
-
@MitchWheat I know. but I am sure the program doesn't create GB-level objects. – Shan-Hung Hsu Apr 03 '18 at 01:33
-
@MitchWheat You're right, I retracted my comment realizing that it wasn't true for individual objects. – Jonathon Chase Apr 03 '18 at 01:35
-
1You are looking at the wrong memory statistic, typically caused by assuming that Task Manager gives good info. It shows RAM usage, it is irrelevant to this problem. It *can* show the relevant one, add the "Commit size" column. That one represents virtual memory allocation size well. – Hans Passant Apr 03 '18 at 06:17
2 Answers
1
If your trying to debug your application, your application will not run with LARGEADDRESSAWARE
(because the vshost.exe is not properly flagged).
How to: Disable the Hosting Process
Also, be mindful of the GC
, it wont aggressively clean up memory in these sorts of situations. So it might be one of the few situations where it would be beneficial to call
GC.Collect()
GC.WaitForPendingFinalizers()
Additional Resouces
GC.WaitForPendingFinalizers Method ()
Also take a look at this question if you havent

TheGeneral
- 79,002
- 9
- 103
- 141
-
Hello, thank you for your answer. I noticed this issue before. I have already unchecked `Enable the Visual Studio hosting process` in project property. This is not the reason cause my problem, but I found the reason now. – Shan-Hung Hsu Apr 05 '18 at 13:55
0
I found the problem finally.
My C# project have some code to detect its memory usage, when it occupy memory over 1GB, it will throw OutOfMemoryException itself. After I comment these code, the program can reach memory usage to 3GB.

Shan-Hung Hsu
- 127
- 2
- 14