I have a problem with memory leak in RenderTargetBitmap function.
Function runs many times. Memory is not released, and at some point there is an overflow.
I tried to free the memory with the help of GC.Collect(). I use:
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
But it does not work. I've read that this is a problem with Net.Framework and the problem has disappeared with version 4.5.2. When compiling the new version of the framework remained a problem.
I have two PC with Windows 10 and Visual Studio 2013, where i can compiling my application. Once, on one of the computers memory leak was not, but after the restart it appeared again.
Related
I am doing C# programming in Visual Studio Code in MacBook Pro, so whenever I run the application, a dotnet process is left in the memory, when I open the Activity Monitor the memory is not disposed, and the CPU is running at 100% even after the debugging is stopped. Is something wrong with my code or is there anything else that I should be doing while writing c# code in Mac OS. Please let me know, right now after every run I am opening activity monitor and force quitting the process.
You just need to have .Net Core and C# extension installed.
The High CPU consumption is often caused by an issue in an extension.
You can open the Process Explorer using Help>Open Process Explorer to view the list of running VS Code processes running in real-time where you'll find what is causing High CPU consumption where extensions are executed by the Extension Host process.
If the High CPU consumption isn't caused by VS Code then it's probably your code and you'll have to optimize it.
You can check the Performance Issues Wiki for more details here
I've got a long running c# application that I'm profiling in visual studio 2017 community edition. Runs for about 2/3 hours before I stop the profiling (and application) to see the CPU usage. However I can see when its building the reports the memory usage increases by 3GB then throws an out of memory exception.
Profiling started.
Profiling process ID 7312 (test).
Starting data collection. The output file is C:\Users\jamie\Source\Repos\test(1).vspx
Profiler stopping.
Stopping data collection.
Merging collection data. Please wait...
Data is saved in file C:\Users\jamie\Source\Repos\test(1).vspx
Profiling finished.
Exception of type 'System.OutOfMemoryException' was thrown.
Is there anything I can do to fix this or do I just have to get more memory?
Oddly the total memory usage on my machine is around 65% when it throws this so its not even using all my memory to build the profiling reports.
This is a fresh install of VS and its got all the default settings.
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
I am having problems with my visual studio 2010 where its memory consumption increases quickly while the application is open. I unistalled all plug ins and now just have the clean version. But while I have the solution open, the memory increases from ~300K to 1GB to such a point if it hasnt crashed, I need to kill the process. The version of the VS is professional and it happens for different solutions.
I feel it may down to the locking on VS2010 config files eating in to memory but thats a guess.
Anyone have similar issues or how I might go about finding what the issues is?
I was having the exact same problem working with large solutions. Give this plugin a try, Solution Load Manager, it lets you essentially "lazy load" projects in your solution, so you only have the ones you're actively working in open and consuming memory.
Worked wonders for me.
I agree with Tipx. Never seen such an issue. My studio hovers around 300MB, but the solution I have open right now has 10 class libraries and 11 web application projects in it.
I'd say open visual studio, start a brand new blank .net solution and let it sit. If it's memory jumps to 1GB, then do a complete uninstall ( http://archive.msdn.microsoft.com/vs2010uninstall ) and reinstall it from the ground up. If it continues exhibiting the behavior on a blank solution then I'd suggest wiping the OS from the machine because something else is really wrong.
If it's memory doesn't climb, then create a blank solution and slowly add your projects into it until something happens. Fix the project showing the behavior.
Of course, if you have a large number of projects OR some third party code is executing on them then 1GB of RAM might be exactly what it needs. I know Telerik's stuff will inspect each project as you click on it to determine if it has the latest version of the controls... I'm guessing others will do something similar.
Create new directory
Move project files new directory (without sln and sou files)
Open project from new location
that's all.
I have application written in C#. Memory usage shows that there is a memory leak. However, dotTrace shows that managed memory is OK, so I think that leak occurs in native memory (yes, there are some native calls in my application). How can I find the problem?
Thanks!
I would take a memory dump of the running application, and then use Windbg or Visual Studio 2010 to investigate the issue.
Related resources:
How to research unmanaged memory leaks in .NET?
Windbg on Wikipedia
Analysing dump files with Visual Studio 2010