locked
Visual Studio running code slow, but code runs fast from command line

    Question

  • I have a C++ application that runs very slow when I launch the application from VS 2010 (using F5) in release mode.  When I launch the same executable from the command line it runs very fast, approximately 10x faster.  I'm trying to figure out why VS would be slowing down the application.  I can also launch the application from the command line and attach VS to the process and then break the code were I need to.  When I do this it runs very fast.  I'm sure it is a setting someplace in VS to allow the code to run fast, but I cannot figure it out.  Below are a few of the options from the project, but if you need more information let me know.  The app name has been removed from the options.   

    Here is my C++ build variables options:

    /I"..\..\include" /I"..\..\libcvd-20100511" /I"..\..\" /Zi /nologo /W3 /WX- /O2 /Oi /Oy- /GL /D "WIN32" /Gm- /EHsc /MT /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /Fp"Release\<< removed app name>>.pch" /Fa"Release\" /Fo"Release\" /Fd"Release\vcWindows7.1SDK.pdb" /Gd /analyze- /errorReport:queue

    and my link options:

    /OUT:"<< removed app name>>.exe" /NOLOGO /LIBPATH:"..\lib" /LIBPATH:"..\..\libcvd-20100511\lib" "Gdiplus.lib" "swscale.lib" "avcodec.lib" "avdevice.lib" "avutil.lib" "avformat.lib" "strmiids.lib" "libcvd.lib" "opengl32.lib" "Winmm.lib" "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /MANIFEST /ManifestFile:"Release\<< removed app name>>.intermediate.manifest" /ALLOWISOLATION /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"<< removed app name>>.pdb" /OPT:REF /OPT:ICF /PGD:"<< removed app name>>.pgd" /LTCG /TLBID:1 /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:QUEUE

    Thanks!


    • Edited by mushadow Wednesday, November 16, 2011 3:00 PM added the attach info
    • Moved by Alexander Sun Friday, November 18, 2011 7:11 AM Visual Studio Editor issue (From:Visual Studio Setup and Installation)
    Wednesday, November 16, 2011 2:56 PM

All replies

  • Hi Mushadow,

     

    Welcome to the MSDN forum.

     

    I am sorry that this queue is about Visual Studio Setup and Installation. Your problem is related to Visual Studio Editor, so I will move your thread to Visual Studio Editor forum for better support.

     

    In addition, since Starting with VS2010, VC++ use MSBuild as the building system which is instead of VCBuild in VS2003-2008. There are lots of changes from VS2003 to VS2010, for break changes, you may refer to http://blogs.msdn.com/b/vcblog/archive/2010/03/02/visual-studio-2010-c-project-upgrade-guide.aspx and http://blogs.msdn.com/b/brunoterkaly/archive/2009/01/26/migration-information-visual-studio-2008-and-earlier-c-net-c.aspx.

     

    Sorry for any inconvenience.

     

    Best Regards,


    Alexander Sun [MSFT]
    MSDN Community Support | Feedback to us
    Friday, November 18, 2011 7:11 AM
  • Hi mushadow,

    What do you mean through the command line? Do you use MSBuild.exe, devenv.exe or others.

    Generally speaking, the difference between the VS IDE and command line is that , the VS IDE has to load the UI and the MSBuild.exe (assume you use the MSBuild.exe).

    You can set the /O1,/O2 option to minimize size and maximize the speed. More information: http://msdn.microsoft.com/en-us/library/8f8h5cxt.aspx

    And you also can try to disable the AntiVirus software (LANDesk) if you have installed.

    Reference :

    VS2010 takes long time to show a project properties

    http://stackoverflow.com/questions/7567060/vs2010-takes-long-time-to-show-a-project-properties

    Performance tips for making Visual Studio 2010 faster?

    http://stackoverflow.com/questions/3097421/performance-tips-for-making-visual-studio-2010-faster

    Serious Build Performance Issue with VS 2010 installed on an isolated system (no internet)

    http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/ba0e096b-0518-4991-9b9b-a5de93db1ed8

    Please mark the useful reply as answer.

    Best regards,

    Lucy


    Lucy Liu [MSFT]
    MSDN Community Support | Feedback to us
    Friday, November 18, 2011 8:31 AM
    Moderator
  • Lucy, as you can see in my first post I already build with the /O2 option.  I don't think it has anything to do with the build as the .exe that is created will run quickly if launched outside of VS.  It must be some setting in VS that is causing this.  So when I say I run it through the command line I mean I just launch the .exe file that was built from the VS IDE.  So here is the whole processes. 

    I make a modification to the c++ code and then want to test the modification.  I press F5 to rebuilt and run the application.  The code runs very slow.  So slow in fact that I cannot test.  (I can run it again without the rebuild and it is still slow)  Then I just go to the Release folder for the project and find the .exe file that was just built from the VS IDE.  I launch the .exe file and my application runs very fast.  I can then "Attach to Process" using the VS IDE, choose my application that is already running and test my modifications.  

    I don't have this issues with any of my other projects.  I can press F5 and the code runs quickly.  I assume it is some setting in VS either with VS hijacking malloc or free, to do some memory leak checks, or something like that.  As far as I know I haven't turned anything on, but I probably did it without knowing it. 

    Thanks,

    Jeremy

    Monday, November 21, 2011 2:21 PM
  • Hi mushadow,

    >>I don't think it has anything to do with the build as the .exe that is created will run quickly if launched outside of VS. It must be some setting in VS that is causing this.

    If you think this issue caused by the VS settings, I recommend you to use devenv.exe /resetsettings” to restore Visual Studio default settings. See whether this issue still exists.

    As you also mentioned that “I don't have this issues with any of my other projects.” I think this issue likely caused by the corrupted project settings .These are project specific. I recommend you to write a new post to a more suitable forum for answer.

     

     

    Best regards,

    Lucy


    Lucy Liu [MSFT]
    MSDN Community Support | Feedback to us
    Tuesday, November 22, 2011 6:42 AM
    Moderator