user1793963
user1793963

Reputation: 1335

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.


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

Upvotes: 16

Views: 12028

Answers (1)

Ross Youngblood
Ross Youngblood

Reputation: 536

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.

Upvotes: 1

Related Questions