简体   繁体   中英

System.OutOfMemoryException when packaging/publishing Azure project

I've been trying to package/publish my Azure project for awhile now (but to no avail). I've tried the following:

  • Right-click -> package/publish from Visual Studio (OutOfMemoryException)
  • CSPack (I closed it after it still kept running even after close to 2 hours)
  • MSBuild (OutOfMemoryException)

How do I circumvent this OutOfMemoryException? I'm currently running VS2012 with 12GB of RAM, so while I think the project is quite large (many, many subprojects), I'd think my machine would be able to handle it. The exception is as follows:

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Windows Azure Tools\2.1\Microsoft.WindowsAzure.targets(2866, 5): error: Exception of type 'System.OutOfMemoryException' was thrown. [C:\Users\..\WindowsAzure.ccproj]

It's been very frustrating, I'd be extremely grateful if anyone could offer me some friendly advice!

This error can occur not just because of the package size. We occasionally receive this error, but a simple restart of Visual Studio resolves the issue.

This is typically caused by trying to place too much content into your package, not by how many projects you reference. There is a maximum size that can be placed into the .cspkg zip stream, and there is a maximum size of .cspkg that can be uploaded to Azure (600 MB).

You should remove all static content such as images, audio, or video from your package and instead place those assets into blob storage. You can change hrefs so that customers directly download the contents from blob storage, or you can use something like the Azure Boostrapper to download content to the VM on startup.

Also, btw, the amount of RAM you have on your machine is in no way related to getting OutOfMemoryException in any application (unless you have too small of a swap file, but that is a different issue).

Figured it out after turning debug logging to diagnostic and running it twice. The exception started popping up when trying to copy/paste the log.

The problem is that the output log is so excessive that it starves the msbuild process running in the same thread for ram. turn the output logging level down, and it should fix it.

Having encountered the exact same problem on a 32-bit machine that had previously been able to build and package the code just fine, I tried all of the above suggestions to no avail. Out of desperation I installed the Azure SDK v2.2 and Visual Studio (2012) and then opened the solution and the build and package steps completed the first time with no errors. I suspect that some of the Azure settings had been changed by a contractor that we hired to help with an upgrade of our CMS (Sitefinity) had used a 64-bit machine and changed the configuration to match his machine when he would run it locally.

So, having 12GB of memory means you should already be on a 64-bit machine, but go look at the Azure settings, or at least which assemblies you are using. it might be that you are including a reference to a x86 assembly somewhere.

Check if you are using the 64bit asp compiler. If not, add this line to your publish profile.

<AspnetCompilerPath>C:\Windows\Microsoft.NET\Framework64\v4.0.30319</AspnetCompilerPath>

Check this link for more informaion

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM