Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set memory limit for debugging in Visual Studio

In an application I'm working on, under certain conditions the memory usage will shoot through the roof, effectively locking up my computer. I don't think it's a memory leak, and there are no errors, it just needs too much memory. The memory usage jumps to 99% in Task Manager and Windows stops working, forcing me to reboot.

Is it possible to set a maximum amount of memory VS can use while debugging? I'm not looking for a way to make it run out of memory faster, I just want to keep some memory free so Windows can keep working.

  • Visual Studio 2010
  • Windows 7 64b
  • 8GB RAM
  • C# .NET

Edit:
I'm not asking how to fix a memory leak. I'm trying to limit the memory used by the VS debugger. For example, my PC has 8GB RAM, but my application has to run on a PC with 2GB RAM. So I want to configure VS to only use 2GB. If the application tries to allocate 2.0001GB I want VS to tell it there is no more memory (probably causing a crash).

like image 537
user1793963 Avatar asked Apr 12 '13 07:04

user1793963


People also ask

How do I allocate more memory to Visual Studio?

Use a 64-bit OS If you upgrade your system from a 32-bit version of Windows to a 64-bit version, you expand the amount of virtual memory available to Visual Studio from 2 GB to 4 GB. This enables Visual Studio to handle significantly larger workloads, even though it is 32-bit process.

How do I debug memory usage?

When analyzing possible memory leaks, you need access to the app's memory heap. Then you can analyze the memory contents. Looking at relationships between objects, you create theories on why memory isn't being freed. A common diagnostics data source is a memory dump on Windows or the equivalent core dump on Linux.

How do I keep debugging in Visual Studio?

In most languages supported by Visual Studio, you can edit your code in the middle of a debugging session and continue debugging. To use this feature, click into your code with your cursor while paused in the debugger, make edits, and press F5, F10, or F11 to continue debugging.


1 Answers

This isn't exactly the answer you were looking for, but it might help others, so I'm posting: I would try the following: 1) Download Oracle Virtualbox 2) Download Disk2VHD.exefrom Microsoft Sysinternals 3) Clone your system using Disk2VHD 4) Configure a VM with the memory restrictions you want.

In this way you can restrict the RAM and CPUs used by your task, and possibly recover easier from the case you describe.

like image 143
Ross Youngblood Avatar answered Sep 19 '22 14:09

Ross Youngblood