12

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.

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
rhunter
  • 183
  • 1
  • 8
  • Maybe give this a look. I have experienced this issue before, but never from executing a command in the Nuget console. Hopefully it helps: http://stackoverflow.com/questions/14186256/net-out-of-memory-exception-used-1-3gb-but-have-16gb-installed – Drew Kennedy Dec 29 '15 at 14:43
  • this means the Virtual Memory of devenv.exe is full. use less VS extensions – magicandre1981 Dec 29 '15 at 14:44
  • @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 less – rhunter Dec 29 '15 at 15:10
  • @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 ago – rhunter Dec 29 '15 at 15:12
  • run vmmap.exe and select the devenv.exe and look how much free virtual memory do you still have: http://technet.microsoft.com/en-us/sysinternals/dd535533.aspx – magicandre1981 Dec 29 '15 at 15:13
  • @magicandre1981 VMMap shows as the task is running the free memory is reducing, at the point the exception is thrown, there is about 400MB free memory available – rhunter Dec 29 '15 at 15:48
  • I also tried running VS in safe mode, so add in should not be enabled, and it still has the same results, free memory is about 600MB at time the exception is thrown, manual refresh, so may be a little out – rhunter Dec 29 '15 at 16:16

5 Answers5

25

Simply restarting Visual Studio worked for me in this case.

Ciaran Gallagher
  • 3,895
  • 9
  • 53
  • 97
4

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

Vivek Nuna
  • 25,472
  • 25
  • 109
  • 197
rhunter
  • 183
  • 1
  • 8
  • Might be worthy telling us the resharper version that you are using. Just for sake of complete information. Cheers, – Gang Gao Jan 06 '16 at 11:40
0

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.

DySoS
  • 105
  • 1
  • 6
0

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

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.

Vivek Nuna
  • 25,472
  • 25
  • 109
  • 197