Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My application is 32 bit and am getting SystemOutOfMemory exception. I am thinking of using LARGEADDRESSAWARE.

Is there any drawback of using it?

What I have tried:

I tried to release unnecessary memory allocation, but that did not help.
Posted
Updated 19-Oct-23 4:55am
v2
Comments
Dave Kreskowiak 19-Oct-23 10:03am    
You should track down what's using all the memory before going to the LARGEADDRESSAWARE route. If you are leaking memory, at best, all you would be doing is delaying the inevitable SystemOutOfMemory.
jeron1 19-Oct-23 10:08am    
It would be pretty quick to enable the linker option and see if it helps the problem.
Are you working with large enough data to account for the exception?
k5054 19-Oct-23 12:02pm    
See this SO response to a related question : https://stackoverflow.com/a/22745579
The author makes some interesting points that relate to using the LARGEADDRESSAWARE flag, that you might want to consider before using it. I agree with Dave and jeron1 : unless you know that you're going to need 2GB of data, you should start by doing some memory analysis and see where all your memory is going.

Using the LARGEADDRESSAWARE flag can be a useful to extend the addressable memory for 32-bit applications running on 64-bit Windows systems.

Before enabling the LARGEADDRESSAWARE flag, it's crucial to carefully assess the memory requirements of your application and consider other strategies to optimize memory usage, such as improving memory management, optimizing algorithms, and reducing memory leaks. Moreover, ensure that you thoroughly test the application with the flag enabled to identify any potential issues related to compatibility, stability, and performance improvements.

Additionally, consider upgrading your application to a 64-bit version if possible, as this would provide more significant benefits in terms of memory utilization and performance.
 
Share this answer
 
No, there are no drawbacks UNLESS you are using a 32-bit OS with about 4GB of memory. Your program can use up to 3GB of memory as a 32-bit app with the LAA flag turned on. In that situation you could find the OS starved for memory and constantly paging so performance will slow to a crawl. This is a fairly unlikely scenario today but I saw it happen about twenty years ago. If that is not your situation then the only real drawback will be that it masks a potential problem. If your program must remain as 32-bit and it must address more than 2GB of memory then that's will you will have to do.

If I were you, I would look at tracking your allocations so you can find where you are leaking memory. MFC has this built in using the DEBUG_NEW macro. If you are not using MFC then take a look at this Memory Allocation Tracking for C++ Code[^] and follow its guidelines.

This is a particularly important issue for me because I write automation applications that must run non-stop for months and months. Memory leaks are an obstacle to program stability and I make sure that my programs have none.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900