Universal Windows App Webview memory leak - clear cache - c#

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.

Related

How to play large no. Of GIF images in WPF, C#?

I need some help in Making a slideshow type application in WPF. Problem is, Image that needs to be used in this application are .gif, for which i think so we dont have any control in WPF.
Does any one have any idea of how to play those images without impacting any kind of performance? Also the machine in which i need to use this application is windows XP, that means the we can only use up to .net 4.0.
What I have tried:
I have tried many examples find over this page, but the memory it consumes is too high as i need to change image more often.
Dll's that i have tried are
wpfanimatedgif:- It has some serious memory leak issues.
also i have tried
XamlAnimatedGif:- it works fine while running on .net 4.5 machine. but was unable to display any image while on .net 4.0 machine.

A part of page stays in memory when you go back. How can I free resources from that old instance of page?

I'm developing an app on Universal Windows Platform. I've noticed that after a few minutes of navigating between pages, my app crashes on low memory devices.
I've tried using Diagnostic tools of VS2015, and here's what I found:
Each time I go from SectionPage to ItemPage and then go back to SectionPage, some small (~10 MB) object of that ItemPage remains in the memory.
This is the first time I went from SectionPage to ItemPage:
(There's one instance of ItemPage)
Then I went back to SectionPage and then opened that same ItemPage:
(Now there's two instances of ItemPage in memory)
Then I repeated it again:
... And the sixth time:
As you can see, those old instances of ItemPage are still in memory.
It seems that this is slowly increasing memory usage of my app, and after a while, it causes the app to crash.
So my question is, how can I release the memory related to that old ItemPage objects?

Freezing managed threads

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 alternatives are available to WMI for obtaining the state of a printer?

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)

Why WPF application process occupy more memory?

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.

Categories

Resources