Sagar
Sagar

Reputation: 421

UWP application is getting slow after usage of some time?

I have developed one UWP application.In that nearly 20 windows are there.

Every window contains lot of Xaml controls. For some time it's working fine.

But after usage of some time application is getting very slow.

After doing some R&D I came to know that it's called Memory Leakage.

As per my knowledge in .Net Garbage Collector has to take care of this if I am not wrong.It seems like In UWP Application it is not happening. So I thought I should use GC.Collect() in Page Unload Event.

Is that correct approach or anything else I need to do to release memory which are used by the window controls?

Upvotes: 1

Views: 935

Answers (2)

MrCSharp
MrCSharp

Reputation: 1143

The GC takes care of orphaned objects or objects that are no longer referenced by any other classes. when the GC finds objects like these it removes them from memory. memory leaks happen when an object is referenced by another class even after it is done with it. this means you need to look at your code and find where this is happening. you need to help GC in doing its job by making sure you no longer reference objects you don't need.
I also wouldn't recommend using GC.Collect in page unload event since GC has to freeze threads in order to collect. this might impact performance.

Upvotes: 1

Anil
Anil

Reputation: 3752

The performance optimization is a vast subject and may not be possible to answer on an open ended question (without knowledge of your environment and architecture etc).

However you can use the Visual Studio profiler to measure and track performance and to find out the area where you need to take action, these can be;

  • Data binding
  • UI Virtualization
  • Image rendering
  • Visual Tree Size

Further reading these urls may also help you.

ms docs and this blog

Upvotes: 2

Related Questions