Hi,
We encounter an issue of CPU usage getting high when typing fast in a TextEdit. Please open the attached sample and reproduce the situation through the following steps.
- Compile and run the sample solution
- Open 'Windows Task Manager ' | 'Performance' tab | 'Resource Monitor' | 'CPU' tab
- Check 'WpfApplication.vshost.exe' in the processes list
- Try to 'fast' type 'different' character s in the TextEdit (Do not press a single key)
- The CPU usage of 'WpfApplication.vshost.exe' reach about 15%
- Close program
- Modify file '…\PerformanceIssue\WpfApplication\pageImageGallery.xaml' and remove all LayoutControl
- Repeat step 1 to step 5, the CPU usage is below 5%
Even though we do not use LayoutControl in an ItemControl, the CPU usage is still affected (CPU usage is around 10%).
Why does a 'user control's LayoutControl' affect the efficiency of a 'TextEdit in the main window'?
Is it a bug or how can we avoid this problem ?
We have placed a lot of LayoutControl in our application and encounter the slow response problem. Please assist resolving the issue.
Thank you in advanced.
Chandler
Screen shot as the attached.
Hi Chandler,
I have profiled your sample, but couldn't determine any performance issues that might be related to the LayoutControl. It looks like the problem is mostly related to the number of visual elements loaded to the application visual tree. I have replaced the LayoutControl to the standard TextBox and obtained similar results. Please check the attached modified sample on your side and let me know your results.
Hi Ilya,
I think the root cause is very obvious.
In you reply, you have placed more than 350 TextBox and the CPU usage is still less than 'three' LayoutControl. In my computer, 350 TextBox sample reaches about 9% CPU usage and 'three' LayoutControl reaches about 15% CPU usage. I think LayoutControl is continuously calculating for some reasons. Could the visual tree of LayoutControl have hundred times larger than TextBox?
I modified the attached sample and replace LayoutControl with Grid/StackPanel. Grid/StackPanel sample only reaches 5% CPU usage. I do think the issue has been determined clearly.
Btw, why does LayoutControl have to be re-rendered or calculate when I am typing in an TextBox out of sight from the LayoutControl? (Actually, if we replace the TextBox with a Button, they almost has the same results.)
Chandler
Btw, please follow 'Windows Task Manager ' | 'Performance' tab | 'Resource Monitor' | 'CPU' tab, I have tried on several profile information. 'Resource Monitor' is the most significant one.
Hi Chandler,
The Grid and StackPanel containers are much more lightweight than LayoutControl and are used for a different purpose. I should say that your scenario is not quite clear to me. Usually, there are only a few LayoutControls on the form. In your sample, you display 150 individual LayoutControl elements - how does this reflect your real life use case? What is the purpose of LayoutControls in your application?
Thanks,
Alex
Hi Alexander,
I did not try to count a number of LayoutControl in our program. The LayoutControl is quite useful and we almost use LayoutControl instead of Grid/Stack panel in our program. As I understand, I do not think the sample code is in a abnormal usage. I just tried to make the sample code clean and addressed the issue. I have made another sample code in the attached. It should be more practical as you wish. CPU usage of 'PerformanceIssue04.zip' still can reach 15% in my computer. You may uncomment a 'Grid/StackPanel' version block in MainWindow.xaml and you will examine a 5% CPU usage (in my computer).
It is obvious that all LayoutControl are continuously calculating/rendering when we are typing in a TextBox. Is it expected by DevExpress? If so, are there any ways that we could stop LayoutControl calculating since the layout has been well arranged at beginning.
Thank you in advanced.
Chandler
All we need is, LayoutControl should not occupy the CPU usage when we typing in a TextBox which is out of sight from LayoutControl.
Chandler
Hi Chandler,
I will check with our developers to see if LayoutControl performs any calculations when you are typing in the TextBox and get back to you.
Thanks,
Alex