12
votes

When I try to add a migration file through PM I get an out of memory exception. Anyone else had this problem before and happen to know how to fix it? So far I have tried re installing VS 2013 to no avail

Monitoring my memory usage I have 12GB available, and it is using less than 8 while the add migration is running, so should be plenty available. Below is the output

PM> add-migration test

System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown. at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
at System.Data.Entity.Migrations.Design.ToolingFacade.Run(BaseRunner runner) at System.Data.Entity.Migrations.Design.ToolingFacade.Scaffold(String migrationName, String language, String rootNamespace, Boolean ignoreChanges) at System.Data.Entity.Migrations.AddMigrationCommand.Execute(String name, Boolean force, Boolean ignoreChanges) at System.Data.Entity.Migrations.AddMigrationCommand.<>c__DisplayClass2.<.ctor>b__0() at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command) Exception of type 'System.OutOfMemoryException' was thrown.

5
Maybe give this a look. I have experienced this issue before, but never from executing a command in the Nuget console. Hopefully it helps: stackoverflow.com/questions/14186256/…Drew Kennedy
this means the Virtual Memory of devenv.exe is full. use less VS extensionsmagicandre1981
@magicandre1981 Thanks for the suggestion, but I only have 12 extensions installed, that includes the ones I cant remove such as microsoft advertising SDKs, and other ones. I have only installed a few myself, not sure I can really use any lessrhunter
@DrewKennedy thanks for the link there. Can confirm that I am targeting Any CPU, and haven't really changed anything there recently. I can confirm that this used to work until a few days agorhunter
run vmmap.exe and select the devenv.exe and look how much free virtual memory do you still have: technet.microsoft.com/en-us/sysinternals/dd535533.aspxmagicandre1981

5 Answers

24
votes

Simply restarting Visual Studio worked for me in this case.

4
votes

Just leaving a note here in case anyone has the same error. I have fixed the issue now. I disabled ReSharper, and it started working. I then re-enabled re sharper and cleared its cache, and it continues to work now with re sharper enabled. Credit to magicandre1981 for pointing me towards the add-ins.

EDIT: The ReSharper version I'm using is 8.2 c# edition, build 8.2.0.2160

0
votes

I had the same issue. I also use ReSharper (2017.2) but do not want to disable it. Instead I disabled all other extensions that I do not use regularly. I also uninstalled all unneeded workloads. This not only solved the OutOfMemoryException but also decreased the project load time tremendously.

0
votes

I just had this happen to me. I slowly retraced my steps, and removed DbSets in the dbContext one-by-one until it worked again.

0
votes

Its solved in Visual Studio 2015 with Automatic feature suspension. You will get a popup like below.

enter image description here

Just click on Re-enable.