none
Increase the memory limit

    Question

  • Hi Everyone

    I try to allocate more than 2 GB in .NET process on an x86 platform.
    For this, I’ve enabled the 4GT RAM mode into my Windows XP kernel. This mode work fine for native process ( after rebuilding my program with a special flag /LARGEADDRESSAWARE) but take no effect on my assemblies (the managed memory limit still stay at 1,5 GB) .

    Someone know how to configure the .net framework for working in large addressing mode ?

    Thanks

    ps : sorry for my poor english ,I hope you understand me ...

    Wednesday, March 07, 2007 9:51 AM

Answers

  • Hi Eric

    Booting the OS into /3GB mode and marking your assemblies as /LARGEADDRESSAWARE, the .NET runtime will allow your app to use up to approx 3GB of address space.  However, depending on how you're allocating, there may not be a contiguous block of memory large enough to satisfy your allocation.  Also, .NET imposes a 2GB object size limit, so trying to allocate an array larger than 2GB will fail.

    If you require more address space that this, you should consider moving to 64-bit.

    See http://www.microsoft.com/whdc/system/platform/server/PAE/PAEmem.mspx for details on 3GB.

    Hope that helps

    -Chris

    Wednesday, March 07, 2007 6:09 PM

All replies

  • Hi Eric

    Booting the OS into /3GB mode and marking your assemblies as /LARGEADDRESSAWARE, the .NET runtime will allow your app to use up to approx 3GB of address space.  However, depending on how you're allocating, there may not be a contiguous block of memory large enough to satisfy your allocation.  Also, .NET imposes a 2GB object size limit, so trying to allocate an array larger than 2GB will fail.

    If you require more address space that this, you should consider moving to 64-bit.

    See http://www.microsoft.com/whdc/system/platform/server/PAE/PAEmem.mspx for details on 3GB.

    Hope that helps

    -Chris

    Wednesday, March 07, 2007 6:09 PM
  • I am having a similar issue.  How do I mark an assembly as /LARGEADDRESSAWARE?

     

    Thanks

    Mike

    Friday, April 06, 2007 9:58 PM
  • Hi Mike


    From the link I posted above:

     

    To set this bit, you must use Microsoft Visual Studio Version 6.0 or later and the Editbin.exe utility, which has the ability to modify the image header (/LARGEADDRESSAWARE) flag. For more information on setting this flag, see the Microsoft Visual Studio documentation.

     

    -Chris

    Friday, April 06, 2007 10:06 PM
  • Excellent, thanks.  I got this to work.

     

    Now, I am trying to automate my build process so that the published smart client app is large address aware.  I have created a .bat file that contains the editbin command, and have added this .bat file as a post-build command and have gotten this to build successfully.  However, when I try to publish my smart client app to a network share, the published .exe.deploy is not large address aware.  Also, only the .exe in the bin\Release folder is large address aware, and not the .exe.deploy in the \bin\Release\publishing directories.

    Monday, April 09, 2007 7:47 PM
  • I think I figured out my own problem.  It looks like the exe that will be published is first created in the obj\release or obj\debug directory, depending on if this is a release or debug build.  Then, the postbuild is run before the .exe is copied to the bin\release\*.publish\publish version directory.  Here are my postbuild commands

     
      $(ProjectDir)postbuild.bat $(ProjectDir)obj\$(ConfigurationName)\$(TargetFileName) $(TargetPath)

     

    and here is my postbuild.bat file

     

    echo off

    call "%VS80COMNTOOLS%vsvars32.bat"

    editbin /largeaddressaware %1

    editbin /largeaddressaware %2

     

    Mike

    Tuesday, April 10, 2007 4:26 PM
  • Excellent script - very useful :-)

     

    I have a space in my .exe filename, so I had to change the postbuild step to:

     

    $(ProjectDir)EditBin.bat "$(ProjectDir)obj\$(ConfigurationName)\$(TargetFileName)" "$(TargetPath)"

     

    (Added some "s)

     

    PS - why is the editbin command run twice? (%1 and %2)

     

    -Torbjørn

    • Proposed as answer by dbooksta Friday, May 07, 2010 8:33 PM
    Sunday, April 22, 2007 9:27 AM
  • Probably because he's passing 2 cmd line arguments to the .bat file - one for the primary .exe and perhaps a related .dll that is being built in the project?  Just a guess.

    The first line adds the setting to the first argument of the .bat file, the second line to the 2nd argument.
    • Edited by alderson21 Wednesday, September 26, 2012 6:08 PM
    Wednesday, September 26, 2012 6:07 PM