- Home /
Build Fails Due To Unity Crash: Out Of Memory
I am running an automated build system using Unity 3.0 Pro on a dedicated server (Mac Pro with 2 quad core Xeons, 16 GB RAM) which autobuilds standalone Windows and OS X Universal players my project every hour as a cron job. This has worked quite well for the past several months, but a few days ago I started getting an "out of memory" message when a normal build was being attempted. Memory use balloon up to ~3 GB and that's the point at which Unity normally crashes. Occasionally it will get to the point of building the players, once again memory use balloons up to ~3 GB, and at that point it will hang up and progress no further.
The code in script (omitting personal information like passwords and such) I am using to build my project is as follows:
/Applications/Unity30/Unity.app/Contents/MacOS/Unity -batchmode -quit -projectPath /path/to/my/project -executeMethod ProjectBuilder.PerformBuild -assetServerUpdate myAssetServer myProjectName myUsername myPassword
The relevant code in ProjectBuilder.PerformBuild is (once again changing some names so it make more sense) as follows:
BuildPipeline.BuildPlayer(sceneToIncludeInBuild, "WindowsBuild.exe", BuildTarget.StandaloneWindows, BuildOptions.Development); BuildPipeline.BuildPlayer(sceneToIncludeInBuild, "OSXBuild.app", BuildTarget.StandaloneOSXUniversal, BuildOptions.Development);
If anyone has run into a similar issue I would welcome some input.
Answer by Josh 4 · Dec 02, 2010 at 02:14 PM
I actually found a way around this several weeks ago. Turns out that the build script isn't necessary if you just want to make a build using the project settings you've set up in the editor. You can use either or both of these command line options: -buildWindowsPlayer path/to/your/build.exe -buildOSXPlayer path/to/your/build.app
Usage, using a modified version of my previous code, is as follows:
/Applications/Unity30/Unity.app/Contents/MacOS/Unity -batchmode -projectPath /path/to/my/project -assetServerUpdate myAssetServer myProjectName myUsername myPassword -buildWindowsPlayer path/to/your/build.exe -buildOSXPlayer path/to/your/build.app -quit
This seems to avoid the problem of having too many assets in the Resources directory. My project has continued to grow and the resolution has endured. These command line options have apparently been in Unity since version 1.0, but they aren't officially documented at this point. Similarly adapting your build process would help you avoid similar problems in the future. It certainly has for me.
It would really have helped if this had been documented with the rest of the command line options. It makes me wonder what else is possible that hasn't been documented.
Answer by Ludovic · Dec 01, 2010 at 03:33 PM
Don't know if you are still stuck by this time but we had a similar problem.
We resolved it when we realized that every asset that is in the Resources folder is built in the player, since it can be loaded everywhere from the code.
Remove assets from the Resources solved our problem.