I would like to ask about memory leak with my C# application. I created an application for get and store data into database. My Application is communicate with another application (client for measurement) through the special DLL library (using WINAPI). The DLL library is working as an TCPInterface.
But, I have memory leak (Im sure, the problem is my application):
After longer time (few days of measurement 24h/day) I open task manager and:
physical memory in Windows task manager is full (after longer time with full memory, computer is working very slow or freeze),
My Application is using about 100MB of RAM (same like on the start and not increase),
Measurement application is using about 120MB of RAM (same, like on the start and not increase),
another processes in task manager are negligible.
And I dont know, where I lost about 4GB of RAM (when I compare list of running processes in Task Manager and Summary of available physical memory).
I tryed ProcessExplorer but without result.
Q1:
Is it possible, that some threads running inside my application are not calculated in memory information of my application in task manager?
Q2:
If the DLL using some physical memory and my application is calling the DLL through WINAPI, where will be counted the amount of used memory of this DLL?
- to my application? ...or where? -how can I see it?
THX for each help.
Related
I have a lot of console applications that run in a scheduler every 10 mins, I see the console applications are completing successfully, all the objects in the code are closed and disposed as needed. I ran processexplorer, perfview, process monitor and was not able to identify any applications hanging around.
But I see all my applications (1000's of them) are showing up in RAMMAP process section all of them with 4K Private bytes, please see screen shot attached.
Please advise is this normal or do i have a potential leak in all my applications? any tool that can be recommended to identify/resolve this issue?
Thanks
I am developing a UWP-App which has a webview control on it.
Most of our code is JavaScript.
The app consumes tons of ram over the time and we have no clue where this memory leak comes from. The is almost no nativ code running, most of it is javascript, we cleared the DOM which is only about 5MB. The size of the app at this moment is about 300MB. I also tried to run the GC with almost no effect.
At start the app has a size of about 50MB, Increasing fast to about 100mb and then slowly consumes more and more RAM. I had a maximum of 1.8GB.
Does anyone has/had the same problem? Is it a equivalent leak than the webbrowser control had?
Update
The cause of the Problem is the growing cache of the WebView. Is there any chance to clear the cache, without closing the app?
As it seams, the problem wasn't the cache, but the Intel App Framework we use.
The Framework we use is an elder version (2.0) which doesn't release the references properly.
An update to version 3.0 solved the problem.
I'm working on a quite big application that is in charge of doing real-time motion tracking and camera movement controlling. Its tasks are:
Motion tracking (done by a native module, which decodes a video stream from a network camera and supplies both image buffers as big as 1280x720 pixels and the tracking results to the managed application via callbacks)
Receiving positioning feedback data from and sending movement data to a pan/tilt hardware about 20 times a second as well as zoom commands from/to the camera
Displaying the image data including live visualizations
Encoding and writing of the image and session data
Automatic postprocessing of the video is done by another process
The application uses .NET 4.0 and has a WPF user interface.
Managed threads freezing
From the beginning we had to face managed threads that freeze for between 500 to 1500ms, which is really much for a real-time application like this.
To find out when these hangs occur I created a thread whose only task is to do a sleep for 100ms all the time. I then calculated how long the sleep really took and got exactly the times when the camera movement stopped. It works very reliably, the threads all hang at the same time!
Unmanaged threads don't freeze
While all the managed threads freeze the unmanaged threads work without any problem. We check that by logs that are written independent from the managed part of the application.
Analysis
I tried to figure out with phenomenons could maybe cause this behaviour:
The whole machine slows down when we encounter these problems: Windows is responding very slowly (e.g. directory listings hang for half a minute in both Windows Explorer and my application, or launching applications takes incredibly long)
We read and write thousands of files at the same time (the tracking and postprocessing application), maybe this overcharges windows
The response of the GUI becomes very slow
The app uses about 1.3GB of virtual memory (according to Process.VirtualMemory64) / 500MB of working set memory (Process.WorkingSet64) - could it be that some of that is swapped onto the harddisk? (How can that be checked or solved?)
Of course if we kill the process Windows is responding fast again, but it takes Windows a while to be responding normally again
Hints on how to investigate into this would be highly appreciated. Thank you very much!
Maybe GC is working?
See the great article: http://samsaffron.com/archive/2011/10/28/in-managed-code-we-trust-our-recent-battles-with-the-net-garbage-collector
I would suggest taking a process dump as you are encountering the performance problem. You can do this several ways (taskmgr.exe or procdump.exe from SysInternals). Take a full memory dump.
Once you have the .dmp file, you can analyze it with windbg (or Visual Studio 2010). For managed processes you need to load the sos.dll extensions.
There are a lot of good windbg resources out there, but here are a few that have helped me:
1) Tess Fernandez video (ASP.NET process, but the techniques are the same)
2) WinDbg cheatsheet
The memory analysis will be able to give you the stack (!clrstack) while you are encountering the problem and tell you the exact culprit.
What options are available in C#/.NET to get the status of an installed printer? The only information we need is if the printer is on or off (we have a little indicator on the screen that says 'Printer ready' or 'Printer offline').
Our application is a small client running on an embedded PC. We've found that the WMI Windows process is running out of memory. Watching it on my development PC there appears to be a memory leak as the amount of memory it uses slowly creeps up. On an embedded device with limited memory this is unacceptable and we're finding after a couple of hours the application crashes.
I would try to resolve the memory leak, but if you cant find it, you could always use PInvoke calls (specifically GetPrinterData). See an example here (Note: There are also WMI posts that could help you compare what you have and see if you can find the memory leak)
I am developing an application using WPF. I am using a lot of Grid layouts. In my application, we use five services to communicate. All works fine. Sometimes, the application slowed way down so I checked task manager to see the memory usage. Then I saw 1.285 GB memory occupied by the application process.
I am using Windows 7 operating system. My Application developed in wpf 4.0 version. In that we use WCF , WIF etc for communication. I also used Images. Can any one give the solution why application process occupies more memory?
All the images are small images.Actually my application occupies nearly 110 MB.But sometimes it occupies 1.238 GB memory.I am not using Large images in my application.
There's no magic bullet answer here for you, it really depends on what you are doing in your application.
Its time to jump into the world of using a profiler and figuring out what is going on in your own app.