Visual Studio Memory Profiling and Breakpoints? - c++

I am using the Memory Usage analysis tool from the Performance and Diagnostics tool (Alt + F2) in Visual Studio Ultimate 2013 Update 4. My project is written using unmanaged C++.
During a memory profiling session, I am really hoping to have Visual Studio trigger several breakpoints which I have set. These breakpoints are triggered just fine whenever I run the program without the profiler, but under the exact same conditions during profiling, they are not triggered.
Is there a way to run the memory profiler with breakpoints?
Note: I know I could use application lifecycle marks or user marks to have them show up in the profiler graph. However, the breakpoints will be far more helpful to root out an issue by stepping through the code whenever I see a change in the memory usage.

Related

Visual studio profiler shows no code was running

Visual studio profiler shows that "No code was running during the selected time range", even when there was clearly code running (the time range was the entire execution time of the program). I have tried to reinstall C++ profiling tools but this issue is still here.

Visual Studio 2015 Diagnostic Tools Memory Usage & C++ Debugging

I have Visual Studio Enterprise 2015 and a native C++ project. I would like to analyze memory usage. Our software runs as a Windows service, so I typically debug by attaching to the running service. I found that when I do that the Diagnostic Tools Memory Usage is not available:
However, when I start the software through the debugger (by pressing F5) the Memory Usage tool shows up:
Is it supposed to be like that, ie. is the Memory Usage Diagnostic Tool not supported when attaching to a process?
The Memory Usage Diagnostic Tool is missing both when attaching to a locally running process as well as when remote debugging (attaching to a process on another machine).
The Diagnostic Tools native memory profiler will support attaching to a process in the upcoming Visual Studio 2015 Update 1. There will be a CTP preview release coming out this Fall that you can try out.

Visual Studio 2015 -- CPU Usage Profiling Not Working?

I recently upgraded from Visual Studio 2013 Community to Visual Studio 2015 Community.
I've heavily relied on the "CPU Usage" Tool that can be found by doing the following:
Click "Debug"
Click "Start Diagnostic Tools without Debugging"
Click "CPU Usage" Check box
Click "Start" button
When the program is complete, it is supposed to show you the functions and the time spent in each. What I get instead is just the name of my executable that I can keep expanding instead of seeing the function names -- It doesn't know the names of the functions.
This worked fine on Visual Studio 2013... I would be able to see the function names and everything worked. I tried creating a new "test" solution/project to see whether this works and I get the same results: No function names.
Does this work for anybody? I also installed VS2015 on a fresh development box and still have no results. This seems like Microsoft shipped with a Visual Studio bug.
Note: I'm writing a C++ console application. I've tried this on debug and release builds and ensured that I'm building with debug information.
It's in the Visual Studio 2015 Update 1 release notes, so I suspect it was broken in the initial release:
Profile your CPU Usage while debugging
Now, you can get a detailed per-function profile of your CPU Usage while you are debugging. You can turn CPU Profiling on and off while debugging and view the results when you are in a break state, which allows you to view a per-function breakdown of CPU Usage of code that executed between breakpoints and during steps. (To use this functionality, open the Diagnostic Tools window (Debug -> Diagnostic Tools), switch to the CPU tab, and then click the "CPU Profiling" button.)
I have also noticed this, but if you use that little search box (top right corner of the results area) and try typing in either the name of the function you're looking for or part of the name and it will expand everything (there's usually a lot to expand) and highlight the function you're looking for. Its the only way I've been able to profile specific functions.

How to save state of Visual Studio C++ debugging session?

I am using Visual Studio C++ 2013. I am running a number cruncher program so it proceeds linearly/predictably. However I have a test which takes several hours to run, before asserting due to logic error in my code. I can get a breakpoint before the crash, but I can't step backwards without starting all over again.
Is there any way to get Visual Studio to save the state of my program, so that I can restart at that point again?
The program state is very complicated and it would take a lot of work for me to save all the state to files myself for resuming later.
When debugging in Visual Studio (even from a breakpoint) use Debug|Save Dump As... to save the current debugging state. When saving, make sure you select "Minidump With Heap" so you have access to heap memory.
Later you can double click the .dmp file to open it with Visual Studio right where you were.
You may consider virtual computers. You can make their snapshots and save them. This may be an overkill, but is guaranteed to work.

VS 2010, performance wizard for unmanaged c++

I tried to use a Performance wizard tool for my short C++ testing in VS 2010 Ultimate.
But for any code the profiling process crashes and the following error occurs:
Could not launch xxx.exe. Injection of runtime library failed.
By this time I used Netbeans and with the VS 2010 profiler I do not have much experience.
I wonder whether this function is available for unmanaged C++... The C++ code is correct...
Configuration: VS 2010 Ultimate, Win 7 Prof. 32 bit.
Updated question:
An instrumentation method works well but the CPU sampling method still does not work.
Yes, the profiler works on native code.
Try running Visual Studio as an elevated admin user.
Check if you have enabled Application Verifer shims for your application.
This problem can be caused by some security or anti-malware program installing hooks in your program, so the profiler cannot get its hooks in. Some vendors provide ways to limit those hooks so you can profile, or you could just try turning it off for a period while profiling.