Memory leak after scheduler refresh

3 posts, 0 answers
  1. Dejo Savicevic
    Dejo Savicevic avatar
    10 posts
    Member since:
    Apr 2010

    Posted 04 Nov 2010 Link to this post

    Hi

    I have scheduler with resources showed in timeline view. Every 5 second scheduler is refreshed (check if there is any changes in scheduler data source). After that, for some reason, resources lose their color (became gray), so they need to be repainted, like this:

    For Each res As Resource In RadScheduler1.Resources
        res.Color = Color.Aquamarine
    Next
     
    To ensure that resources are repainted, I need to call this part of code:
    Dim schtimelineGrouping As TimelineGroupingByResourcesElement = TryCast(RadScheduler1.SchedulerElement.ViewElement, TimelineGroupingByResourcesElement)
    schtimelineGrouping.RefreshViews(True)
    schtimelineGrouping = Nothing

    And it seems that this procedure RefreshViews make a problem with memory leak.
     
    To be sure, I created a test application which every 5 second execute only coloring and refreshing of scheduler resources, for example:
    For Each res As Resource In RadScheduler1.Resources
        res.Color = Color.Aquamarine
    Next
         
    Dim schtimelineGrouping As TimelineGroupingByResourcesElement = TryCast(RadScheduler1.SchedulerElement.ViewElement, TimelineGroupingByResourcesElement)
    schtimelineGrouping.RefreshViews(True)
    schtimelineGrouping = Nothing
    In a short period of time (1 hour) application increased memory usage from 44MB to over 100MB.

    In a real application memory usage growth to more than 1.5GB, and than Out of Memory exception occurred. For a testing purposes application was working almost for a 24 hours. 
     
    Is this a good approach of resource coloring, and how this can be fixed?

    Thanks.
  2. Dobry Zranchev
    Admin
    Dobry Zranchev avatar
    348 posts

    Posted 12 Nov 2010 Link to this post

    Hi Dejo,

    Thank for reporting the issue and please accept my apologies for the delayed response.

    I was able to reproduce the issue and I updated your Telerik points accordingly. You could avoid calling the RefreshView(true) by using the following approach:
    TimelineGroupingByResourcesElement viewElement = this.radScheduler1.SchedulerElement.ViewElement as TimelineGroupingByResourcesElement;
     
    foreach (RadElement element in viewElement.ResourcesHeader.Children)
    {
        SchedulerCellElement cell = element as SchedulerCellElement;
        if (cell != null)
        {
            cell.BackColor = Color.Pink;
            cell.GradientStyle = GradientStyles.Solid;
        }
    }
    foreach (Resource res in this.radScheduler1.Resources)
    {
        res.Color = Color.Pink;
    }

    With the help of this code snippet you can change the color of the header element directly instead of re-created the view. In addition, this is not a time consuming operations.

    I hope this helps. If you need additional assistance, feel free to contact us.

    Sincerely yours,
    Dobry Zranchev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Dejo Savicevic
    Dejo Savicevic avatar
    10 posts
    Member since:
    Apr 2010

    Posted 15 Nov 2010 Link to this post

    Hi Dobry,

    Thank you, this was helpful.
Back to Top