none
Memory leak in Pivot V2 ?

    Question

  • I started using the new PivotViewer that came with SL5.

    I have an Image class as the the template for the PivotViewerItemTemplate.

    Looking at the Task Manager, when going back and forth between the screen that contains the pivot, and another screen, I've noticed that each time the memory consumption of the Silverlight app goes up by 150 MB !! ( And we are talking about only 30 items ).

    It's important to note two things :

    1. Each time when you enter the pivot screen, a new instance of the pivot is created.
    2. When using a TextBlock (for example) instead of the Image for PivotViewerItemTemplate, the issue still remains, but with smaller memory increases.
    Can anyone report having the same issue ?
    Friday, December 23, 2011 4:37 PM

Answers

  • Task Manaager isn't a real good measure of memory usage.  SL and IE takes it time in garbage collection if there is available memory.  So you might not actually have that leak.

    If you are creating a new PV each time you load a page, then yes it would jump if garbage collection hadn't cleared out the old one yet.

     

    Friday, December 23, 2011 5:45 PM

All replies

  • Task Manaager isn't a real good measure of memory usage.  SL and IE takes it time in garbage collection if there is available memory.  So you might not actually have that leak.

    If you are creating a new PV each time you load a page, then yes it would jump if garbage collection hadn't cleared out the old one yet.

     

    Friday, December 23, 2011 5:45 PM
  • It seems that, efectively, there's a memory leak in PivotViewer V2 (Silverlight 5) that avoids Pivot instances to be garbaged. I'm using ANTS Memory Profiler tool (by RedGate) to profile my applications and PivotViewer instances never get garbaged.

    To demonstrate this issue I've created a very single demo project with a pair of view model classes:

    public class ViewModel
    {

    public ViewModel()
    {
    Items = new ObservableCollection<Item>();
    AddNewItemCommand = new DelegateCommand(o => Items.Add(new Item()));
    ClearAllItemsCommand = new DelegateCommand(o => Items.Clear());
    }

    public DelegateCommand AddNewItemCommand { get; private set; }
    public DelegateCommand ClearAllItemsCommand { get; private set; }
    public ObservableCollection<Item> Items { get; private set; }
    }

    public class Item
    {

    }
    So, ViewModel class contains an ObservableCollection of items and two commands: AddNewItemCommand that inserts a 
    new Item to the ObservableCollection and ClearAllItemsCommand that clears the collection. In MainPage.xaml code is 
    as simple as:
    <UserControl.Resources>
    <local:ViewModel x:Key="ViewModel"/>
    <DataTemplate x:Key="ItemTemplate">
    <sdk:PivotViewer Height="200"/>
    </DataTemplate>
    <Style TargetType="Button">
    <Setter Property="Margin" Value="5"/>
    </Style>
    </UserControl.Resources>
    <Grid DataContext="{StaticResource ViewModel}" x:Name="LayoutRoot" Background="White">
    <Grid.RowDefinitions>
    <RowDefinition Height="Auto"/>
    <RowDefinition/>
    </Grid.RowDefinitions>
    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
    <Button Content="Add new Item" Command="{Binding Path=AddNewItemCommand}"/>
    <Button Content=" Clear all" Command="{Binding Path=ClearAllItemsCommand}"/>
    </StackPanel>
    <ItemsControl Grid.Row="1" ItemsSource="{Binding Path=Items}" ItemTemplate="{StaticResource ItemTemplate}"/>
    </Grid>
    That's just an ItemsControl where ItemsSource property is bound to the Items property in ViewModelClass and a pair of buttons
    bound to both ViewModel commands.
    That's all. Profiling the application with ANTS Memory Profiler 7.5 (for example) you can watch how the number of PivotViewer
    instances grows up although you click the "Clear all" button to reset the Items collection.
    
    
    Tuesday, May 08, 2012 10:17 AM
  • Any word about this Issue. Is this control definitely abandoned? Or there's some one who can resolve bugs?

    If Microsoft has decided to do not offer support for this control, at least, they could publish the source code.


    Daní

    Thursday, January 24, 2013 3:39 PM
  • I've encountered this as well, no luck in resolving it however.

    We are using 4 viewers with different collections, after windbg and ANTS it looks like the pivot viewer creates items that are unable to be GC collected which ties down the Writeable bitmaps in memory. 

    Thursday, May 16, 2013 7:27 AM
  • I am having the exact same problem, any news on this?

    Thanks

    Henrik

    Wednesday, September 25, 2013 11:22 AM