Graphics
Intel® graphics drivers and software, compatibility, troubleshooting, performance, and optimization
20589 Discussions

.Net WPF Application high memory consumption

Simon_HE
Novice
7,463 Views

Hello,

 

I noticed an issue using a .Net Framework WPF Application with Intel GPUs.
If the application is running on computers with inte GPUs, the memory consumption is about 10x increased, compared to other GPUs or without the Intel driver.

 

I was able reproduce it on a minimal configuration with the following components:
- Empty .Net Framework 4.8 WPF - Application created from the stock Visual Studio 2022 Template (See WpfTest.zip)

- Clean installed Windows 10 22H2 with driver version 31.0.101.3790
- Intel i9-12900 with 64GB memory.

 

After the installation, without Intel drivers at all, the demo used ~15MB of memory.

With the 31.0.101.3790 driver installed, memory usage jumped to 145MB.
Uninstalling the driver or deactivating the Intel GPU via device manager gets it down to 15MB again, after minimizing and maximizing the window

(Memory usage values shown in TaskManager)

 

The change in memory usage is also visible if a second GPU is installed in the system and screens are connected one of the GPUs.
Connected to Intel GPU: High Memory usage
Connected to Nvidia GPU: normal usage.

 

Using the drivers provided by HP for the computer (30.0.101.1002  and 30.0.101.1273) showed no change.

(The ssu.txt attached is from my working windows installation on Windows 10 21H2 on the same machine with same results)


Is this a known issue? If so, is there any workaround?

Thanks

0 Kudos
19 Replies
ChrisV
Novice
7,426 Views

Yes, I can confirm this problem.

Using WPF applications on one of my workstations that has an Intel UHD Graphics 770 consumes ridiculously higher memory even from the startup. Afterwards it continues to build and build on the memory. In the attached pic you will see my WPF app where I have 4 instances of it, all only with software rendering, except one where hardware rendering is activated. Look at the memory!!

If I change the graphics card to a NVidia, everything goes normal. I had clients that were complaining about OutOfMemory problems, and I could not find why for an awfully long time. We had to add an "only software" rendering option to the app so it could work on these computers.

 

We just added this at program startup (optionally), and everything fixed, although the program is quite sluggish without hardware rendering.

RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;

 

Simon_HE
Novice
7,402 Views

I noticed the improvement with software only rendereing as well, however it's not a real solution for us.


We draw a good amount of charts in our application and use 3rd party elements in the UI.

As you said, applications start to feel sluggish using software only rendering, especially on weaker endpoints like laptops
In addition, each of the 3rd party components needs to be configured for software rendering on its own.

 

0 Kudos
Alberto_R_Intel
Employee
7,321 Views

Simon_HE, Thank you for posting in the Intel® Communities Support.


I just wanted to check if the problem with high memory consumption persists and if you still need assistance on this matter?


If you do, just to confirm:

This problem with memory consumption, is it recently, or has it happened before?

When did the issue start?

Did you make any recent hardware/software changes that might cause this problem?

Does the problem happen at home or in the work environment?


Regards,

Albert R.


Intel Customer Support Technician


0 Kudos
Simon_HE
Novice
7,309 Views

Hello Albert,

 

Thanks for your reply.

Yes, the problem still exists as the workaround using software rendering described above comes with serious performance degradation.

I started to maintain the software recently, but as far as I am informed, the issue existed since at least a year and was recently traced down to the Intel driver/iGPU being the trigger. However, reports of issues date back at least two years.


Previously we mainly used computers with dedicated graphics and started to switch to computers with integrated graphics only but had to stop that as issues with memory consumption flooded our helpdesk.
We didn't make any changes to the software showing the problems as it's the empty WPF .Net Framework application shell provided by Microsoft and the memory issue is observed on multiple devices (different CPU/iGPU) generations)

It's a company environment.

 

Looking forward to getting this resolved.

 

Simon

 

ChrisV
Novice
7,295 Views

Hi Albert,

the same as Simon mentioned. We also have many clients with the same problem. And I am sure that other .Net WPF developers have the same issue but have not pinpointed the problem to the GPU yet and trying to guess what is going wrong with their apps on those specific machines.

 

Best Regards

Chris

Cabal
Beginner
7,277 Views

I'm creating a WPF program for kiosk in full screen running 12 hours/day every day. I have test in my home for memory usage since sometimes it becomes lag and slow. I run the program with task manager on top of the screen and start clicking the function on the screen. I see the memory increase when going to another page.

Every navigation will increase at least 50MB and most consume when next page is displaying a list of images. When timeout arrive and navigating back to home page, the memory still not decrease. I wonder why the memory is increasing.

Does WPF application not release the memory usage after going to another page?

If this still continue for a few hours, the program will crash.

How to encounter this problem actually?

I'm using WPF Application with Page (not Window).

 

The Calculator service demonstrated below represents the scenario:

C#
public void Add()
{
    MathClient.AddAsync();
}
Public void Sub()
{
    MathClient.SubAsync();
}
public void Add_Completed(object sender, EventArgs e)
{
    //Process Result
} 
Public void Sub_Completed(object sender, EventArgs e)
{
    //Process Result
}

In the above code which returns the result first and which returns result last, the developers will not be able to predict, it will be hard to block the UI thread till all results are returned. Hard to synchronize all items. It will be very difficult to dispose service. The services have the inner Channel which is unmanaged and need to be dispose or else memory consumption will be high. There are many instance we see where Silverlight or WPF application hangs the UI, which makes the application very unfeasible at the production.

The service call has to be made in synchronous fashion to avoid all these issues.

Since almost all the code have delegates and events, it consumes more memory, long processing time, and since everything is asynchronous here it can lead to instability in the code, which has to be addressed.

There are chances that same service is called many times, causing unnecessary roundtrip to the server, may also impact on the bandwidth, where you see only data-transfer consumes more memory than web applications, the performance will also have an impact, causing long time to update UI.

KSmart pattern for WPF

Here by I present my custom design pattern which solves most of the problems incurred in WPF development, by making application development easier, keeping low memory, increased stability, increased performance, lesser network bandwidth.

The detail of the KSmart pattern will be presented separately in-detail in another code project article, which contains comparisons of various design patterns with KSmart pattern.

 

Basically I have also run this but unable to solve the same -

 

I have also developed POS application and WPF many times consumes much memory even when idle.
Even by following the above links(Provided in Solution 1),sometime a part of memory is not cleared(i.e. memory leak remains). Basically I have to use this on my development purposes for mobile app development company . But GPU is running so much higher.
Please find the code below and use it in some common space like where window is unloaded.
This will remove your much part of Memory but will not clear Memory Leak left by your code(like this will not remove your event handlers if you have not unregistered them but if you open report viewer and call this code after closing report viewer you may find the difference).

Declare this

C#
[DllImport("KERNEL32.DLL", EntryPoint = "SetProcessWorkingSetSize", SetLastError = true, CallingConvention = CallingConvention.StdCall)]
       internal static extern bool SetProcessWorkingSetSize(IntPtr pProcess, int dwMinimumWorkingSetSize, int dwMaximumWorkingSetSize);

       [DllImport("KERNEL32.DLL", EntryPoint = "GetCurrentProcess", SetLastError = true, CallingConvention = CallingConvention.StdCall)]
       internal static extern IntPtr GetCurrentProcess();



Consume this code

C#
IntPtr pHandle = GetCurrentProcess();
            SetProcessWorkingSetSize(pHandle, -1, -1);


 

0 Kudos
ChrisV
Novice
7,257 Views

Hi Cabal,

I don't think the memory leak you are describing is the same as described in this thread by me and Simon. I have not used WPF with pages, so I do not have any experience with it. 😞

 

Best Regards

Chris

Alberto_R_Intel
Employee
7,282 Views

Hello Simon_HE, You are very welcome, thank you very much for providing that information.

 

According to the SSU report, the graphics driver currently installed on your computer is version 30.0.101.1273. Which, as you mentioned, that driver is provided by HP and it should be the proper one for your platform since it was tested, validated, and customized by them:

https://support.hp.com/my-en/drivers/selfservice/swdetails/hp-z2-mini-g9-workstation-desktop-pc/2101025774/swItemId/wk-289856-1

 

Since the issue remains also when installing our latest graphics driver version 31.0.101.3790:

https://www.intel.com/content/www/us/en/download/19344/intel-graphics-windows-dch-drivers.html?wapkw=uhd%20graphics%20770

 

We will do further research on this matter, as soon as I get any updates, I will post all the details on this thread.

 

Regards,

Albert R.

 

Intel Customer Support Technician

 

0 Kudos
Alberto_R_Intel
Employee
7,157 Views

Hello Simon_HE, I just received an update on this matter.


After working on this case, it is important to mention that we were unable to replicate the issue in our Intel® lab. 


Based on that, we determined that the issue does not seem to be related to Intel® Graphics drivers. At this point then, we recommend for you to check and test your configuration since the source of the problem seems to be related to the platform that you are using.


Regards,

Albert R.


Intel Customer Support Technician


0 Kudos
Simon_HE
Novice
7,103 Views

Hello Albert,

 

this is unsatisfying for our side.
On what platforms did you test the demo from the first post and what were the memory values observed.

As described in the first post, a big change in memory consumption is observed when performing the following steps:

 

1. Start the demo application with the newest Intel Graphics driver (31.0.101.3790) installed and ensure the application is displayed on a Screen connected to the Intel GPU.
-> Memory consumption of 150MB or above is observed

2. Disable the "Intel (R) UHD Graphics 770" Device via device manager
alternatively
Uninstall the Intel Driver
or
Plug the Screen into a non-Intel GPU (Only tested with Nvidia so far)

3. Minimize and Maximize the application (Restarting the application has the same effect)

-> Memory consumption should drop quickly below 25MB

4.  Revert the Steps from 2

5. Minimize and Maximize the application (Restarting the application has the same effect)

-> Application Memory rises again to ~150MB or more

 

The demo application is the empty template from Microsoft, it does not contain any changes

 

If you have trouble replicating the results above,  please contact me.
(unavailable till 09.01.2023)

0 Kudos
Simon_HE
Novice
7,103 Views

Edit: It looks like my posts are disappearing shortly after posting. If the older posts come back again, please delete the duplicates

 

Hello Albert,

 

that's bad to hear as we had to stop ordering of new computers until the issue is resolved.

Which part of the issue were you unable to replicate? What platform and driver were you using and how much memory was consumed?

I just tested again with multiple WPF applications, including 3rd party ones.

To reproduce it, use the following steps:

I used the demo application from the first post on a i9-12900 using Driver 31.0.101.3790
Ensure that the screen is connected to the Intel GPU if the system has multiple.

 

Start the demo application.
-> Memory consumption should be ~150MB
Deactivate the "Intel(R) UHD Graphics 770" Device via device manager
or
Uninstall the driver
or
reconnect the screen to a non-Intel-GPU
Minimize and maximize the application, alternatively restart it.
-> Memory consumption drops be below 20MB
Revert action from step 2
Minimize and maximize the application, alternatively restart it.
-> Memory consumption should rise again to ~150MB

 

If you have problems replicating the steps, please contact me.
(I'm unavailable till 09.01.2023 due to holidays)

The same change, with different numbers, is also present on 3rd party applications using WPF.

 

Regards

Simon

 

0 Kudos
Alberto_R_Intel
Employee
7,099 Views

Hello Simon_HE, Thank you very much for your response.

 

We completely understand your comments. In reference to your questions about the lab we have performed, please see the SSU and two videos attached to this post.

 

In the videos from our lab, you will be able to see the memory usage for the application while running on Intel® Graphics with driver 3790. We ran the project with no debugging and you can see the WpfTest stayed at around 15 MB of memory usage.

 

While starting the project, and also debugging the WpfTest increased to 23.5 MB of memory usage, which is expected and is way less than the increment presented in this scenario.

 

If you have more questions or need more details about the tests we did, please let us know so we can further asist you.

 

Regards,

Albert R.

 

Intel Customer Support Technician

 

 

0 Kudos
Alberto_R_Intel
Employee
7,038 Views

Hello Simon_HE, I just wanted to check if the information posted previously was useful for you and if you need further assistance on this matter?


Regards,

Albert R.


Intel Customer Support Technician


0 Kudos
ChrisV
Novice
7,033 Views

Please retry these tests with Intel Integrated UHD cards 730 or/and 770. Not 750.

On our side, we do not have reports of clients with problems with the 750 model.

 

Best Regards - Happy Holidays

Chris

0 Kudos
Alberto_R_Intel
Employee
6,994 Views

Hello ChrisV, Thank you very much for your answer.


At this point, we are waiting for Simon_HE's response since the resolution on this matter was already provided to him.


In this case, as an alternative, you can always submit your inquiry on a new thread as well, since every scenario is different even if the same product is being used:

https://communities.intel.com/community/tech


Let me apologize for any inconvenience.


Regards,

Albert R.


Intel Customer Support Technician


0 Kudos
Alberto_R_Intel
Employee
6,694 Views

Hello Simon_HE, Since we have not heard back from you, we are closing the case, but if you have any additional questions, please post them on a new thread so we can further assist you with this matter.


As an option, you can always get in contact directly with HP support, making reference to this thread, for further assistance on this matter:

https://support.hp.com/us-en


Regards,

Albert R.


Intel Customer Support Technician


0 Kudos
Simon_HE
Novice
6,613 Views

Hello Albert,

 

sorry for the late response.
The issue still persists on our side.
Is it possible to test the issue against the Hardware specified by ChrisV and me? (i9-12700 with UHD 770)

 

Regards Simon

0 Kudos
ediwang
Beginner
5,475 Views

I have the same issue on i9 13900H CPU with Iris XE graphics.

Even a pure empty WPF app takes 165.2 MB on startup. This is a .NET 6.0 WPF application, not .NET Framework, same issue.

ediwang_0-1681177936970.png

It is normal on other machines

ediwang_1-1681177974573.png

I am using the latest driver 31.0.101.4255, the issue is still there.

Just like you said, disabling the CPU integrated graphic will make WPF memory usage normal. But using software rendering or disabling Iris XE isn't a solution.

 

I created an issue in WPF repo for Microsoft to investigate the problem. 

https://github.com/dotnet/wpf/issues/7704

0 Kudos
Simon_HE
Novice
5,422 Views

Glad to see that i'm not the only one with this problem.

As Intel did no longer respond to this thread, my issue was continued here, sadly without intel being able to replicate it.

https://community.intel.com/t5/Graphics/Closing-of-topics-without-solution/m-p/1446417

 

0 Kudos
Reply