.NET application memory usage Visual Studio 2005 - c#

I've got a C# application running on Windows CE smart device and I recently added a new graphing option which results in a "OutOfMemory" exception after running for a few hours. How do I find what is going wrong? The code looks fine, its based on one of the previous graphing options that runs for weeks without a problem.
I've tried the Debug > Windows > Memory options in VS 2005, but they all give the message "Unavailable when debuggee is running." I've also tried attaching to the process using the remote debugging tools (specifically the Windows CE Remote Process Viewer), but there's not enough functionality to see what I'm looking for.
Are there tools in VS 2005 to analyse either a remote C# app or one running locally (ie. Win32)?

a) see Memory profiler for .NET Compact Framework
b) see CF remote performance and ... viewer: http://www.microsoft.com/en-us/download/details.aspx?id=13442&751be11f-ede8-5a0c-058c-2ee190a24fa6=True
looks like you have a memory leak in code.

Related

Is There Such A Thinig As a C# Application Link Map Or Something Equivalent?

Is is there a C# build construct available that would allow me to create a link map containing symbols and offsets? I need to debug an application that is throwing an exception when running scheduled out of Task Scheduler.
Here are some details of what is going on: I have developed a C# application on Windows 10 Workstation (non-server). I am trying to run this application on Windows Server 2012 R2, which, like the Windows 10 system, has .net framework 4.5.1 installed.
The application runs with no known errors on the development workstation, whether it is run installed or out of Visual Studio 2012.
However, the application will not run at its scheduled time out of Windows Task Scheduler. This is the error 0xE0434352 -- I have been reading SuperUser and stackOverflow posts about this error -- and the Windows application event log shows an exception has occurred.
However, the offsets in the application event log are not a lot of help without having a map of the executable.
Is creating a link map or equivalent possible?
Here is a link to one description of a linker map for gcc.
in .Net the assemblies are self-describing. A debug database file is useful, but not necessary to describe the objects and how the code is structured. So I would not think a link map are relevant for .net assemblies.
You might want to take a look at dnSpy, this is a combined de-compiler, debugger and assembly editor. It is often useful when trying to debug errors. It is however limited to managed code, so it will probably be less useful if the error is in native code.

Profiling managedCuda in Nsight or Visual Profiler

I'm trying to profile an CUDA-application written in C# with managedCuda using either Nsight Visual Studio Edition or Visual Profiler. Both profilers work well with a plain C++ CUDA app. To test the profilers with managedCuda I want to profile the project "vectorAdd" in ManagedCudaSamples.
First I tried to use Nvidia Nsight Visual Studio Edition 5.0 integrated in VS 2013. I use the x64 Debug configuration. If I try to launch the app in "Application Control" in Nsight Performance Analysis I get an error message:
Analysis Session - Start Application
Unable to launch 64-bit managed application '...\ManagedCudaSamples\vectorAdd\bin\x64\Debug\vectorAdd.exe'.
Additionally I tried to use Nvidia Visual Profiler 7.5 for profiling the same application. On running vectorAdd.exe nvprof console shows the following output:
==2944== NVPROF is profiling process 2944, command: ...\ManagedCudaSamples\vectorAdd\bin\x64\Debug\vectorAdd.exe
==2944== Warning: Some profiling data are not recorded. Make sure cudaProfilerStop() or cuProfilerStop() is called before application exit to flush profile data.
==2944== Generated result file: ...\nvvp_workspace\.metadata\.plugins\com.nvidia.viper\launch\7\api_2944.log
I'm new to CUDA and would be thankful for any advice how to profile managedCuda applications.
You need to call CudaContext.ProfilerStop() just before you exit the application (or destroy the context) in order to flush the collected data to the profiler. The managedCuda samples don't include this call why the profiler doesn't see the collected info. This explains the second error you get.
And regarding the first error:
In the release notes of Nsight 5.0 you can find a known issue:
Managed applications built with the AnyCpu configuration are not supported. The target application must be built using either the Win32 or x64 configurations.
The VS-project for vectorAdd is always set to AnyCPU, regardless what the solution platform is, see the configuration manager of the managedCuda samples-solution to change that.

Intellitrace and Windows Services

I'm trying to run IntelliTrace on a Windows Service, but encountering some issues.
I've (generally) tried the steps that are detailed here: http://blogs.msdn.com/b/msaffer/archive/2011/02/23/using-intellitrace-with-services.aspx.
I've tried VS 2013 Update 3 IntelliTrace download (from Microsoft) and also the new collector thats included with VS 2015 Enterprise RC. Both respond the same.
So:
Test service, registered, running as an administrator (so it's not access rights).
An Environment key has been created with the following values:
COR_ENABLE_PROFILING=1
VSLOGGERCPLAN=C:\Intellitrace14\collection_plan.myplan.trace.xml
COR_PROFILER={AAAAAA70-DFED-4CB4-A1D6-920F51E9674A}
(This is the CLSID that is registered for 2015 RC it seems)
When I start the service, it fires up but in the Event Log I get:
The profiler has requested that the CLR instance not load the profiler into this process.
I've tried with both a 32-bit and 64-bit compiled service (and the relevant IntelliTrace being registered).
I know that Windows services aren't realy a supported target for IntelliTrace, but it did used to work with 2010 etc -- has something really changed for the current versions or am I missing something?
Here is a blog post that explains how to collect data from a windows service in production using IntelliTrace. http://bit.ly/1bTfcIO
If you have any issues following this guide you can also contact me directly at angelos.petropoulos#microsoft.com
On a related note, here is also the announcement that IntelliTrace in Visual Studio 2015 Enterprise now also supports attaching to a running process. http://bit.ly/1bT1Psn This means you can also attach to a running windows service without restarting it.
This post is a bit old and you may have figured it out already... but I had the same issue and, after much searching, a bit of screaming and a lot of trial and error, I finally hit on the problem. The environment setting is very sensitive to extra spaces. Once I cleaned out spaces around or next to the equal signs and from the end of each line, IntelliTrace worked for me.

Analyzing memory dump to find leak

We have a c# .NET application that has a memory leak in it. I used procdump to get a memory dump from a running instance of the application from a production machine. The production machine is running 32 bit Windows XP, and .NET 4.0.
The exe config is set to .net 4.0
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
When I pull the dump to my dev box, windows 8.1 64bit, and open it with VS 2013 the dump is initially opened fine. However, when I click the Debug Managed Memory action I get the following error message:
Memory analysis is not supported for the CLR version used in this process.
I'm new to troubleshooting memory leaks in Windows and managed memory environments, and know next to nothing about the tools involved. I did a google search for the error I get, and didn't find anything. Any help is appreciated. I apologize if I am missing something obvious - Junior Dev here :-)
I don't know if procdump can be used to find a memory leak in .NET. One effective way I tried is: using Windbg and SOS. There are two posts explains how to use Windbg+ SOS to track .NET memory leaks:
Where's your leak at? [Using WinDbg, SOS, and GCRoot to diagnose a .NET memory leak]
Debugging managed code memory leak with memory dump using windbg
If you don't like Windbg, the tool DebugDiag is also very effective tool in tracking down memory leaks.
See this link, it only works on process running under .Net 4.5
Before I begin, there are a few things to note about the "Debug
Managed Memory" feature discussed in this post:
The option will only be available from the dump summary page in the
Ultimate version of Visual Studio 2013. If you are using Premium or
Professional you will not see the option
The process the dump file was collected against must have been running on .NET 4.5 or higher. If the dump was collected on 3.5 or
previous the option will not appear, if it was collected on 4.0 it
will fail to launch with an error message.
Starting with Windows 7 /Server 2008 R2 there is a way to create a clone of a process and create a dump of this clone so that the process you care about doesn't need to be suspended. Use procdump -r to use this feature when capturing a dump.
You can also use capture a ETW trace and analyze the data with PerfView.
https://superuser.com/questions/846079/how-can-i-create-a-memory-dump-of-a-production-system-without-affecting-performa/846156#846156

C# WinForms App won't run on Win7 after Building

I have a program that I built that reads and writes files. I built it in Release mode, then tried to run the exe on Win7. At first, with troubleshooting on, Windows simply told me the application closed and it was looking for a solution. After a few seconds, the dialog would disappear and show nothing more.
So with some significant effort I got the debugger attached to the process, but it was only showing me disassembly, which tells me that the error taking place wasn't in my application code, but in the framework somewhere.
The strange thing is that when I let the debugger attach, then press "stop" in VS, and exit the debugger, the program actually runs at that point!
So now I'm stumped. I have an application that builds, that seems to be having a permission error when I run it, but if I let the debugger attach then close it, it runs, and there's no Exception to really look at.
How I troubleshoot this issue?
Edit: Responding to Merlyn:
It's a custom app written from scratch in c#. The only dependency it has outside of core .NET namespaces is the Ionic.Zip DLL.
Visual Studio 2008 (Writing in C# 3.5)
Windows 7 - Home Premium, v6.1 build 7600
CPU - x64 quad core
CPU are you compiling under: Any CPU
I haven't tried it on another machine or a different version of VS.
Edit: I was able to try the compiled version on another win7 computer, and it worked without issue, so it looks like a security (?) issue on my computer only.
Try it in the debugger with Just My Code disabled and Native Code enabled, then check the call stack.
Also, what happens if you run it directly in Visual Studio?
Uncheck Enable Visual Studio Hosting Process in Project Properties and see whether it still works in VS.
I'd suggest sending the issue to Microsoft support. Especially with the data given here, you will have an easy time convincing them it's their problem. You might need an MSDN subscription for that.

Categories