This is a migrated thread and some comments may be shown as answers.

RadListBox memory leak

5 Answers 168 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Alex
Top achievements
Rank 1
Alex asked on 23 Apr 2017, 10:42 AM

Hello,

I'm using telerik control tools for WPF UI ver: 2015.1.0401.45

I have noticed that radlistbox has a huge memory leak. On replacing radlistbox with Microsoft listbox, memory leak does not occur.

I'm attaching the demo project (replace extension of file from  .jpg to .zip).

This project demonstrates the problem of memory leak. Actually the memory leak occurs on data binding

I've remarked the Microsoft listbox in xaml, so to prove my claim, just use Microsoft listbox instead  of radlistbox and see the difference in memory usage of the processes.

Do you have a patch to fix this issue ?

Thank you,

Alex

 

5 Answers, 1 is accepted

Sort by
0
Kalin
Telerik team
answered on 26 Apr 2017, 12:03 PM
Hello Alex,

We checked the attached project and tested the scenario using RadListBox and ListBox, however we were not able to notice any difference in the memory consumption. One thing we noticed is that you are creating UI elements and using them as ItemsSource of the ListBoxes. However in such scenarios is recommended to bind the control to data objects and use ItemTemplate in order to achieve the desired look. I have modified the attached project - please check it.

Hope this will help you.

Regards,
Kalin
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Alex
Top achievements
Rank 1
answered on 26 Apr 2017, 02:14 PM

Hello Kalin,
Thank you for the answer. 
First of all there is a difference with memory consumption in my demo project.

In case of radlistbox the memory usage always grows up (see attachments)  and in case of listbox is not.

About using ItemTemplate, I can't use it the way you are suggesting because I have many types of srips (not one like in demo project). All strips are inheriting from interface and I can't use interface as the ItemTemplate in xaml.

Thank you,

Alex.

0
Kalin
Telerik team
answered on 28 Apr 2017, 06:57 AM
Hello Alex,

When you need to apply different templates depending on custom logic - you could use the ItemTemplateSelector in order to implement that logic. For more details on the data binding support of RadListBox, please check the following article:
http://docs.telerik.com/devtools/wpf/controls/radlistbox/populating-with-data/binding-support-overview

Hope this helps.

Regards,
Kalin
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Alex
Top achievements
Rank 1
answered on 30 Apr 2017, 09:23 AM

Hi Kalin,

Thank you for the answer.

Your answer did not really helped me. You didn't relate to the images I've provided one post before, that shows the memory leak every time the ItemsSource is changing. The same data using Microsoft listbox doesn't have the same problem.

 If you don't have a solution / fix for it , it's ok for me , but please provide me the answer.

Thank you,

Alex.

0
Kalin
Telerik team
answered on 03 May 2017, 01:46 PM
Hi Alex,

Indeed RadListBox uses more memory compared to the WPF ListBox in this scenario. However if you leave the application running for a while you would notice that the memory drops from time to time (whenever the garbage collector kicks in). I tested the app with memory profiler and actually after the garbage collection, the memory used by the removed objects is being released.

If you test the following snippet you would see the memory being release immediately the new object are created:

private void auto_refresh_strips_timer2_Tick(object sender, EventArgs e)
{
    Strips = GetStrips();
 
    GC.Collect();
    GC.WaitForPendingFinalizers();
}

However we recommend using data binding in this scenario in order to achieve the best possible performance.

Hope this helps.

Regards,
Kalin
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
ListBox
Asked by
Alex
Top achievements
Rank 1
Answers by
Kalin
Telerik team
Alex
Top achievements
Rank 1
Share this question
or