Search code examples
.netvisual-studio-2012azuremsbuildout-of-memory

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!


Solution

  • 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).