Not enough storage is available to complete this o

2019-01-24 01:40发布

问题:

Environment:

  • Visual Studio Ultimate 2010
  • Windows XP
  • WPF Desktop Application using .NET 4.0

We have a desktop application which plays a video. This video is part of a project and the project is packaged into the installer. Every once in a while building the installer project shows this error message:

Not enough storage is available to complete this operation

If I restart Visual Studio it works.

Is there a way to avoid this? Is there a better way to package videos in an installer?

回答1:

This usually happens when the build process needs a lot of RAM memory and cannot get it. Since restarting Visual Studio fixes the problem, most likely it also your case.

Try closing some of the running applications. You can also try adding more RAM to your machine or increasing the page file.



回答2:

Problem

In my case, the problem was with a test project containing a very large (1.5GB) test file as an embedded resource. I have 16GB RAM in my machine with 8GB free when this occurred, so RAM was not the issue.

It is possible that we are hitting the 2 GB limit that the CLR has on any single object. Without delving into what MSBuild is doing under the hood, I can only speculate that during compile time, the embedded resource is loaded into an object graph that is hitting this limit.

The Error message is very unhelpful. My first thought when I saw it was, "Have I run out of disk space?"

Solution

It is a file validation test project. One of the requirements is to be able to handle files of this size, so on face value my team thought it reasonable to embed it for use in test cases.

We fixed the error by moving the file onto the network (in the same way that it would be accessed by the validator in production) and marking the test as an integration test instead of a unit test. After-all, aren't unit tests supposed to be fast-running?



回答3:

I came across this question when trying to compile my C# solution in Visual Studio 2010 in Windows XP. One project had a fair number of embedded resources in (the size of the resultant assembly was ~140MiB) and I couldn't compile the solution because I was getting the

Not enough storage is available to complete this operation

error in my build output.

None of the answers on this question helped, but I did find an answer to "Not enough storage is available to complete this operation" by ScottBurton42 on social.msdn.microsoft.com. It suggests adding the 3GB switch to the Boot.ini file, and making devenv.exe large-address aware. Adding the 3GB switch to my Boot.ini file was what worked for me (I think devenv.exe for Visual Studio 2010 and above is already large-address aware).

My answer is based on that answer.


Solution 1: Set the /3GB Boot.ini switch

The page Memory Support and Windows Operating Systems on MSDN says:

The virtual address space of processes and applications is still limited to 2 GB unless the /3GB switch is used in the Boot.ini file.

The /3GB switch allocates 3 GB of virtual address space to an application that uses IMAGE_FILE_LARGE_ADDRESS_AWARE in the process header. This switch allows applications to address 1 GB of additional virtual address space above 2 GB.

The virtual address space of processes and applications is still limited to 2 GB, unless the /3GB switch is used in the Boot.ini file. The following example shows how to add the /3GB parameter in the Boot.ini file to enable application memory tuning:

[boot loader]
timeout=30
default=multi(0)disk(0)rdisk(0)partition(2)\WINNT

[operating systems]
multi(0)disk(0)rdisk(0)partition(2)\WINNT="????" /3GB

Note "????" in the previous example is be the programmatic name of the operating system.

In Windows XP, the Boot.ini file can be modified by going to

  • System Properties → Advanced → Startup and Recovery → Settings → System Startup → Edit

The page on the /3GB switch on MSDN says:

On 32-bit versions of Windows, the /3GB parameter enables 4 GT RAM Tuning, a feature that enlarges the user-mode virtual address space to 3 GB and restricts the kernel-mode components to the remaining 1 GB.

The /3GB parameter is supported on Windows Server 2003, Windows XP, and Windows 2000. On Windows Vista and later versions of Windows, use the IncreaseUserVA element in BCDEdit.

Restarting the machine will then cause the setting to take effect.


Solution 2: Make devenv.exe large address aware:

  1. Open up a Visual Studio Command Prompt (or a Developer Command Prompt, depending on the version of Visual Studio)

  2. Type and execute the following command line:

    editbin /LARGEADDRESSAWARE {path}\devenv.exe`
    

    where {path} is the path to devenv.exe (you can find this by going to the properties of the Visual Studio shortcut).

This will allow devenv.exe to access 3GB of memory instead of 2GB.



回答4:

Cleaning And rebuilding the solution worked for me



回答5:

In my case, I had very less memory left in C drive. I cleared few items from C drive and tried again. It worked.



回答6:

I might be late to answer but for future reference, you might want to check the Windows dump file settings (and probably set it to none).



回答7:

In my case the server I was executing the code on couldn't handle my parallelized code.

Normally I'm running a setup like the following

new ParallelOptions { MaxDegreeOfParallelism = Math.Max(1, Environment.ProcessorCount / 2) }

Introducing a variable and allowing lockdown of cores used to 1 (resulting in code like the following), resolved this issue for me.

new ParallelOptions { MaxDegreeOfParallelism = 1 }


回答8:

The key for me: We had embedded a huge database template (testing had filled it with lots of data) into the application. I have not seen this issue arise since removing Embedded Resource boils properly and moving the database to a recourse folder.



回答9:

My fix this problem with delete or disable(exclude) the *.rpt files that have large size;and I've optimize the my reports!



回答10:

I am late to Answer but may be useful for others In my case just restarting Visual Studio fixes the problem



回答11:

For Visual Studio, you can try to do the following:

  1. Close All Visual Studio instances.
  2. Open Visual Studio Developer tool in Administrator mode.
  3. Navigate to:
    C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE.
  4. Type following:
    editbin /LARGEADDRESSAWARE devenv.exe.
  5. It's worth also to restart PC.

Hope this helps )