Lazycoder

27Dec/050

Visual Studio 2005 memory leak

I’m looking over a few samples in VS 2005 and I notice that my tray has popped up a little bubble informing me that my virtual memory is running low. WTF? I’ve got a gig of RAM on this box and all I have open is one instance of VS 2003, one instance of VS 2005, Outlook 2003, and two instances of IE. Sure I’ve got a lot of stuff in the tray, but I’ve still got 1 GB of RAM (and change) in this machine. I shouldn’t be running out should I?

I pop open Task Manager and notice that one instance of devenv.exe has it’s mem usage listed as 132MB?! Wow, I wonder which one it is? I right click and “end process” and the VS 2005 instance winks out of existance. So I try some experiments. First I open a new instance of VS 2005. Just sitting on the start page, it’s mem usage slowly crawls up to 24MB and hovers there. This is about where my other instance of VS 2003 is. Now I had 5 projects open in VS 2003 so already I’m using more RAM with vs 2005 and I haven’t even done anything yet. So now I open up a Winform project I’ve been working on. It contains 3 forms and only opens one in the visual designer when I open the project. WHAM, mem usage shoots up to 85MB and stays there. I had expected that when I closed that project, the usage would go back down. But it doesn’t. It stays at 81MB. So now I open a web project. Now it shoots from 81MB up to 127MB by the time the project completely loads. What’s going on here? So lets close the web project, mem usage goes down to 123MB. So now, just by opening and closing two projects, I’m using 100MB more memory than when I first started? Can anyone on the VS team tell me what is being cached or leaked? Usually I look at GDI objects if I suspect a memory leak, but task manager is showing 461 which doesn’t seem too unreasonable for a GUI as complicated as VS.
I thought, “Maybe devenv is caching my previously opened projects?”. So I open the Winforms project again, it does open faster. But mem usage goes up to 139MB.

Very strange behaviour. Is there a service pack out already for VS 2005? I wish I had time to properly profile this app to see if I could shed anymore light on this behaviour. If it is leaking, it’s cleaning up after itself because the memory is reclaimed once I close VS 2005.

Filed under: .NET Leave a comment