Compiled program runs MUCH slower after I switched to VS 2010 - visual-studio-2010

One of our critical company apps (C#) crunches hi-rez images, and we've made great efforts to optimize it. It performes over 2.5 million operations in ~ 2.5 seconds.
We've used VS 2005 for years, and last week, moved everything over to VS 2010.
Same exact project code.
Now, when I build the app and run it (outside the VS 2010 IDE), the very same operation takes 5 + seconds every time.
This is a big issue, and absolutely hurts my brain. I currently have it set to Release mode (same as I had it in VS 2005).
Any idea what could be causing a doubling of the execution time when the code is precisely the same?

You are probably seeing the change because you switched from targeting the .NET 2.0 runtime to the .NET 4.0 runtime.
You mention you highly optimized the code for performance. My guess is that some of the optimizations are actually hurting your performance rather than helping it now (since internal implementation details of the Framework that you relied on for optimization have changed).
My suggestion would be to run your code through a Profiler (like Redgate's ANTS Performance Profiler or JetBrain's DotTrace) and see where the new bottlenecks are. You can move forward from there.

Related

While developing in the Visual Studio 2013 IDE, CPU spikes and it becomes very laggy

The problem
When using Visual Studio 2013, Ultimate update 5, the IDE becomes very laggy (not running anything), and CPU spikes eating consistently around 30% up to 100% CPU.
Particulars (what I am doing when this happens)
This happens quite often and doesn't seem to be dependant upon any specific project. I have tried re-installing (fresh), as well as from scratch (format, reinstall windows, install ONLY visual studio + a very moderate suite of developer controls [2 well known companies (DevExpress, and Telerik)])
What is also very odd, is this happens even when developing a console application, although it takes much longer for this to occur.
The system I am running is more than adequate (according to their specs required), and Visual Studio is really the only application experiencing this lag + cpu spike issue.
(notice the cpu spike to 58%. this was also visual studio doing that in the background)
This is not a code issue, but an issue somehow with the IDE itself. What I am hoping for is a solution involving something that I may need to tweak / adjust / disable / etc which is contributing to this. As an aside, I really have no idea why there are so many handles open when Visual Studio is running. 91k seems quite excessive.
Another issue (pointing it out as it may be related), when publishing a project, after publishing, Visual Studio keeps automatically checking 'Click Once' when I have explicitly disabled it. This needs to be unchecked after every time I publish or else the next publish/compile/test run, results in an 'mscorelib' message complaining that the pdb doesn't exist, even though it does, and I have used it in other projects. What is frustrating about this problem is that I am telling it I don't want the project to be clickonce, and after it builds a non-click once project for publish, Visual Studio enables it effectively making this checkbox useless and wasting valuble time having to do this after each publish. Time, that adds up -- especially with the persistent lag.
I am confident I am not the only one who has experienced this due to reproducing this issue on a fresh and bare setup of both the operating system, and visual studio with nothing else aside from two popular component suites. As such, this is my attempt to reach anyone else who has experienced this, and if you did find a solution (or cause), to lend a hand to me.

How do I stop Visual Studio 2010 from crashing when working with large solutions?

I work on a rather large solution with teams across the planet. We currently have 49 large projects and a lot of dependencies.
Unfortunately, I only have 4GB of ram and frequently have a low virtual memory error. This usually happens when I begin typing. I already increased my virtual memory to 10GB but that doesn't seem to be enough and I don't have the drive to space to spare to make that number any bigger.
While I was hoping it was just a memory leak somewhere in Visual Studio rebooting doesn't seem to do much help. Getting a better machine is highly unlikely and I have no desire to set precedence of spending personal funds on new equipment. I already disabled all plugins.
Aside from disabling intelisence, are there any tweaks I can perform on VS2010 ultimate to minimize crashing when working with a large large solution?
If it hurts, don't do it. Just break your project into smaller solutions. You only need the master solution for automated builds, and even that is debatable.
Visual Studio is a 32bit application. There is no way you it is going to use more than 4GB of RAM no matter what you do.
Make sure you have all the patches applied, especially the service pack. Visual Studio 2010 RTM was really unstable, but SP 1 seems to be ok.
Keep complaining until you get a machine with 6 GB physical RAM and a fast hard drive. While VS can't use more than 4, you still need RAM for the OS.
Make sure Intellitrace is turned off. While debugging that is a huge performance hit even if you have a small application.
Do you have static code analysis or code contracts turned on? Both of these can be memory hogs. (These days I normally run them only for Release builds.)

Are you upgrading to Visual Studio 2010 or are you forced to stay with 2008 (or worse)

We are on VS 2008 at the moment and it's very hard to convince management that we should move to 2010 (we have just recently upgraded to 2008...).
I wonder if there are many of you with the same problem at the moment, or maybe you had a similar situation and managed to push the change in your organization somehow? I'd be happy to read some ideas of how you did it.
If it's hard to convince, this may be an indication that there is no enought value in your upgrade project than you thought.
Or, you are trying to convince them with wrong features.
Upgrading to VS2010 will increase your productivity, and therefore decrease their costs.
New debugging and testing features justify, alone, the upgrade.
Let's see if your management are smart enough to both make your happy and decrease their costs ;)
More info: http://msdn.microsoft.com/en-us/library/dd547188.aspx

Visual Studio 2010 - How to optimize

I am using the 2010 version of Visual Studio, but am having many problems with delays - my computer has a good configuration of RAM, and processor - especially when saving files.
Currently I am carrying a medium-sized project, only one open file (ASP.NET page) using a single suite of components from third party, the Telerik. And yet, in time to save, or modify the tab, the entire IDE is slow. I know there may be several factors for this problem, but I'm not carrying the computer (the problem apparently is the memory management on behalf of the IDE).
Does anyone know any way to improve it? Change settings, Windows services. Oh yes, I'm using a plugin to modify the color of the IDE and another to find (Ctrl-click) the object reference.
Memory Initialization:
Memory: 280000K
Virtual Memory: 350000K
Have you tried disabling all the plugins and make sure that it is VS that actually causes the slowdown?
I have Resharper installed and VS can be slow sometimes. I turned it off (suspend on v5), and VS is back to blazing speed. Of course, inversely coding productivity is impaired by not having Resharper.
There are many causes and circumstances that can lead to what you're describing. So I'd better recommend you to check the links bellow...
VS.Net 2010 IDE Very Slow
VS 2010 very slow
VS 2010 slow for edit of first file in project with many web references
VS2010 C#: Delay when opening a file inside IDE

Is there any risk while using Visual Studio 2010 Beta 2?

Is it safe to use the beta versions of Visual Studio?
By safe I mean, while developing any project in this studio, is it probable that it may cause some losses to my project? Or any other kind of risk?
Should I just use the studio 2008 and
wait for the stable version of Studio
2010?
Purpose of the question: I am doing my graduation project in .NET framework (includes - C#, WPF etc.).So I don't want to put my project at any risk because of some issue regarding (beta) visual studio.Hence the question.
As long as you are using a version control system, there should be no problem. Simply check out your project (or better yet, create a vs2010 branch) to an experimental folder and work from there.
There are no hidden risks when you use version control appropriately.
Visual Studio 2010 will convert your project files to its new format, meaning you'll have trouble if you want to go back to VS2008 later. I'd suggest holding off for now unless you can find a way to keep both old and new versions of the project files up to date.
There's always a risk in using beta software (but then again, there's always a risk in using any software). The whole reason it's called beta is because the company is not confident that it's got all the bugs worked out. Otherwise, it would have been released so they could start raking in the moola.
There are quite a few ways to mitigate the possibility of any beta software (not limited to VS2010 or even any programming-related product) from causing you trouble. Choose any from this list, which is by no means exhaustive:
Don't use it on the same data (be it accounting information or source code) until you've run it in parallel and gotten the same results as with the older version.
Plan a backout strategy if the software is so bad that it's easier to go back than to try and go forward.
Backup your data even more frequently during the periods where you're using the beta software, up until the point that you're comfortable with it and can revert to a more normal backup strategy.
Don't use beta software at all - wait for the real release (or SP1 if you want to be even safer). There may not be a driving force behind updating to the latest version.
As a company, limit your exposure to the beta software to a small set of your employees. So, for example, if you have six different teams, choose the least important as a sacrificial lamb, so to speak.
My own personal preference is to wait until everyone else has sorted out the problems first. I didn't upgrade to the latest Ubuntu while it was in beta (I still got burnt a little bit with the video and X but that particular problem already had a solution on the net). I don't download the latest and greatest Eclipse until it's been in use for a few months. I'm still using VS2008 under Windows XP since there's nothing I think I need in the latest release (of VS or Windows).
We obviously have the latest and greatest OS' in our test environments but they're crash-and-burn environments that won't cause any real pain if they blow up (other than a rebuild but even that's pretty painless nowadays).
For your particular circumstance, I would probably stick with a tried and true version. You don't seem to have a pressing need for any of the new features in your question and the sort of failure you're talking about is not just losing some information at work which, while annoying, is probably backed up to the point where your career would survive.
A similar loss of your educational work would affect you for a long time if you fail your subject because of it. I would probably just concentrate on getting it finished rather than worrying about what VS2010 beta might do to my work. Don't misunderstand me, you should still be protecting your work even with VS2008 but I'd personally feel safer with that option.
Then, if you have some spare time at the end of your project (hah! as if that would happen!), you could try to convert what you've done so far to VS2010. If it all goes pear-shaped, you still have all the VS2008 stuff available.
There is certainly risk in using unproven software in that it could behave unexpectedly. Some of the answers here focus on protecting your source code and that is a valid concern, but you should also consider other risks.
Could Visual Studio 2010 make your system unstable? Having your source code in a local instance of source control won't do you much good if Visual Studio corrupts your hard drive. Even if you backed up regularly, you'd still be out a good day or two (MINIMUM) rebuilding your desktop.
Also, what do you intend to do with the finished product? Will a professor attempt to open the project on their own desktop? Are you expected to deploy it to another environment? We see these "Works on my computer" problems using proven software, a beta certainly increases the probability of running into this type of problem.
So yes, there is certainly increased risk in using a beta. You can take steps to mitigate the risks but with important work those are steps you should be taking anyway. Is the benefit of using Visual Studio 2010 worth the increased probability of delays / data loss / grade impact?
I know I'm experimenting with VS2010 and I haven't seen severe problems but betas are not proven/guaranteed - the overall risk is probably slight but it is a risk nonetheless.
I guess I would approach the question differently...Is there any real value in using VS 2010 over 2008? I have been using both for a while and I would say, No.
I have had some mysterious crashes with VS 2010 and the application has disappeared on me, causing me to lose any unsaved data.
If you are integrating IronPython / Ruby or working with Office or VB style COM, there is more support for this in .NET 4.0. Beyond that, most of the changes add some shine to the IDE, but not much real value.
my 2 cents.
The biggest risks you will face are crashes, random tool window misplacements, and occasionally Visual Studio will refuse to start and you will have to reset all your settings to have it working again. 1 (I am anyway reasonably happy with Visual Studio 2010 and don't regret having installed it; in my case the compelling reasons were unit testing and visual designer for Silverlight)
But as ocdecio says, there should not be danger for your code, especially if you use a source control system.
As an additional advise, target your projects to .NET Framework 3.5. Using a beta development tool may be ok, using a beta .NET Framework in a production environment is usually not.
1 This crash is supposed to be caused by using raster fonts for the code editor, but it has happened to me without using this type of fonts.
Given that you've said the project will be "tested on another system", the answer is simple: use VS2008. VS2010 solutions cannot be opened by earlier versions, and I wouldn't bet my graduation project on whether or not someone else has VS2010 installed.
Other reasons to stick with VS2008:
VS2010 probably doesn't gain you much.
There are bugs, and I'd rather be working on getting my graduation project done rather than working around problems with my development tool.
If you need help along the way, those that can potentially help probably aren't using the same version. That may make a difference, it may not.
Another thing to consider.. usually the EULA prohibits you from deploying and/or shipping a product using a Beta version of the toolset. I'm not sure this applies in your situation but it's a point to consider.
Another potential issue I've heard of is that sometimes Visual Studio betas refuse to uninstall when it comes time to put in the RTM version. So as long as you don't mind reinstalling Windows when you're ready to install RTM and you've taken the other answers into consideration, then go ahead.
Since your project is for a graduation project and not for full production release, I would say use the latest/stable version of Visual Studio 2010.
You will gain more than you will lose as you will be using the latest technology which will be more useful going forward.
There is an issue for touch screen machines which may render WPF applications unusable.
A workaround exists. See details:
‘MS.Win32.Penimc.UnsafeNativeMethods’ Threw An Exception
fix: C:\Windows\Microsoft.NET\Framework\v3.0\WPF>regsvr32 PenIMC.dll
The biggest problem I have with VS2010 Beta 2 is designer. The Windows Form Designer generates buggy code (Microsoft Connect bug id 507267 and 499925). So I have to edit the form in older version of Visual Studio
I have a few other problems not related to code lose, like random crashing and wizard disappearing.
I've just spent two weeks in VS 2010 beta 2 doing some serious prototyping work. It all went pretty smoothly, and I really like VS 2010. At the end, I moved all the code back to VS 2005 and integrated it with my current project. My experience:
Moving the code back to 2005 was pretty easy. I did try not to use any C# features from 2008 or 2010. The only thing I missed was C#'s implicit properties, but those are easily fixed.
Yes, the project and solution files are not backward compatible. To migrate back, I just created new projects in 2005, and pasted the source files in through Visual Studio. Worked like a charm.
I did find one thing that would consistently crash 2010. If you use the splitter to view two different sections of a file at once, and cut-and-paste from one pane to the other, VS 2010 will roll over and die pretty quickly (not necessarily at the time of the cut-and-paste, but very soon afterwards).
There are some nice productivity features in 2010. You can drag a tab out and make it a window. In Windows 7, you can drag it to the top of the screen to maximize, or to the side to use have the screen. Dragging one file to one side of the screen, and another file to the other side, means you get the whole screen to edit two files, side by side. Very nice. (Even better on two monitors, but I was on a laptop.) The "Quick Find" dialog can now be docked -- that's a huge improvement.
As others have mentioned, use source control, but VS 2010 really is not unstable enough to be any more of an issue than VS 2008. Note that Team Foundation Server 2010 is also available in beta, and will be part of all MSDN subscriptions. It installs under Win7 and Vista. I'm using it for source control on my laptop! Team Explorer is integrated into VS 2010.

Resources