0

I have a serious Performance issue in my Silverlight project, when I run my project the CPU usage is going up 80% - 90%

the computer go down!!!, these are the major feature of the project:

1- We are using Silverlight 4.

3- We are using MVVM pattern, which means all data source, states are Binding with the properties in the View Model.

4- Most of the controls are created dynamicly in code.

5- We have a reference for the Main control in the Main view model which is the container of all generated control.

6- In our controls we have many of layouts (Grids).

7- We have Main view model which is the container of all children view models in the system.

8- We have lots of states and animations.

9- We don't use the Relay commands, we are using the regular commands and events, so we raise the event and handle it's parent (we have lots of events).

Is there any of the above causes the performance problem??? I thinks that there is a issue in the Silverlight itself, is there any Silvelight 4 update for performance.

I appreciate any help,

Thanks

Saad
  • 374
  • 5
  • 19
  • 2
    Without code, it is impossible to help. I wouldn't be so hasty to blame Silverlight though. First try using a profiler to see what is going on. Besides, there are a gazillion MVVM implementations and frameworks, what are you using? A home-grown one, a framework like MVVM Light or Caliburn.Micro, something else? – Panagiotis Kanavos Mar 11 '11 at 11:14
  • 1
    Have you run your code through a performance profiler? That will tell you more than any of our guesses. If I had to guess, I would start looking about the state and animations, also look at creating the controls dynamically (ie. do you really need to all of them at once etc) – Stuart Blackler Mar 11 '11 at 11:15

3 Answers3

0

A complex application is likely to have performance issues to resolve. The use of data-binding and various events, while great for structuring your application, can make it hard to see what's going on. The control flow may not be obvious, for example code may be executing multiple times due to cascading events/property changes.

I'd recommend using a profiler to see what is consuming most CPU time - JetBrains DotTrace is one I've used with Silverlight, see other questions for more. Then you can focus on the problem areas.

If your application is becoming progressively slower over time, it would be worth investigating whether there are memory leaks also.

Community
  • 1
  • 1
Nicholas W
  • 2,231
  • 1
  • 14
  • 15
0

Are you using DropShadowEffect anywhere? In which case, you might want to try removing them. I've had this issue once. A template included a DropShadowEffect which made the CPU max out, removing it solved the problem.

Einarsson
  • 522
  • 2
  • 14
0

In my experience, your 9th point is usually the culprit.

Make sure that you release the event handlers in your classes when you're done with them. In almost all cases where I've seen performance degradation in Silveright or WPF is was the improper handling of event delegates.

As one of the comments pointed out, use a performance profiler and you'll most likely see that the event handlers are consuming an inordinate amount of RAM...meaning that they're sticking around after they're supposed to, and responding to events.

So the performance issue stems from having many objects or controls staying in memory and responding to events.

That's my best guess.

Hope it helps.

SergioL
  • 4,905
  • 3
  • 26
  • 30