none
What are the limits for Memory allocation ? RRS feed

  • Question

  • Hi,

    for an upcomming project I need to know the limitations .NET gives me.

    I need to hold a large number of little objects > 50.000.000 in Memory. The size of those little objects is about up to 100 Byte. This would result in the need of holding ~ 5GB

    Is there any way to achieve this goal ?

    In my current test program I achieve to hold up to 10000000 of those little objects before I hit the Syste.OutOfMemoryException. Physical Memory is not the issue. I have 14GB available in my Win7 64bit,  I7 Machine.

    Thanks for any hints and feedback!

    Regards
    Rainer

    Saturday, January 19, 2013 2:35 PM

Answers

  • Make sure you are building with AnyCPU or x64 platform target (see project properties, build page). If you don't then your application will run in 32 bit mode and it can't take advantage of all the physical memory you have.
    Saturday, January 19, 2013 2:39 PM
    Moderator
  • "I am building with AnyCPU, but still run into the "System.OutOfMemoryException"."

    Have you checked in task manager if your app really runs in 64 bit mode?

    "Is there "something special" I have to do to get more virtual memory?"

    Hmm, not really. As long as it runs in 64 bit mode 5GB shouldn't be a problem. How much memory does it use when the exception is thrown? 

    • Marked as answer by Rainer Queck Saturday, January 19, 2013 3:18 PM
    Saturday, January 19, 2013 3:04 PM
    Moderator

All replies

  • Make sure you are building with AnyCPU or x64 platform target (see project properties, build page). If you don't then your application will run in 32 bit mode and it can't take advantage of all the physical memory you have.
    Saturday, January 19, 2013 2:39 PM
    Moderator
  • Hello Mike,

    thanks for answering.

    I am building with AnyCPU, but still run into the "System.OutOfMemoryException". Is there "something special" I have to do to get more virtual memory?

    Regards
    Rainer

    Saturday, January 19, 2013 3:01 PM
  • "I am building with AnyCPU, but still run into the "System.OutOfMemoryException"."

    Have you checked in task manager if your app really runs in 64 bit mode?

    "Is there "something special" I have to do to get more virtual memory?"

    Hmm, not really. As long as it runs in 64 bit mode 5GB shouldn't be a problem. How much memory does it use when the exception is thrown? 

    • Marked as answer by Rainer Queck Saturday, January 19, 2013 3:18 PM
    Saturday, January 19, 2013 3:04 PM
    Moderator
  • Hi Mike,

    I think I found the reason why I ran into out of memory.

    In the general section for the project settings, there is a checkbox "Prefere 32 bit" which was checked by default. I unchecked it, and now I can allocate my 50 million objects without any problem.

    Thanks for your assistance. Knowing, that 5GB should not be a problem helped me to locate the cause!

    Regards
    Rainer

    Saturday, January 19, 2013 3:17 PM
  • "there is a checkbox "Prefere 32 bit" which was checked by default."

    Right, that's a new option introduced in VS2012. It makes a AnyCPU app use 32 bit even when the app runs on a 64 bit OS.

    Saturday, January 19, 2013 3:22 PM
    Moderator
  • Thanks, Mike. Good to know that one for those of us who have had to set some of the similar settings to get our apps to work cross platform.


    Mitch Bird

    Tuesday, January 22, 2013 4:30 PM