locked
Memory leak in Viewport3D RRS feed

  • Question

  • I have discovered a memory leak related to Viewport3D.  Below is a XAML user control that should replicate the scenario.  It only leaked on one of my systems.  It runs much smoother on the XP box (much better video card).

    Leaking  system:
    Windows XP SP3
    ATI Radeon HD 3600

    Non-leaking system:
    Windows Vista Utlimate SP1
    GeForce FX 5700LE

     
    <!--Viewport3D leak tester  
        Run this sample xaml (.NET 3.5 sp 1 required) in xamlpad, kaxaml, IE   
        or where ever.
          
        Then it run for several minutes...  
        Open Task manager (or preferably sysinternal process explorer) and obserse the hosting process increase memory footprint
          
          
        --> 
    <UserControl Name="viewport3DLeakTest"   
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        Height="501.767" Width="315.063" Background="Transparent" > 
     
        <UserControl.Resources> 
            <ResourceDictionary> 
                <!--A simple square plane --> 
                <MeshGeometry3D x:Key="MeshGeometry3D_Plane" Positions="-1,1,0 -1,-1,0 1,-1,0 1,1,0" 
                                        TextureCoordinates="0,0 0,1 1,1 1,0"   
                                        TriangleIndices="0 1 2 0 2 3"/>  
     
                <!--A Tiled drawing brush that filld a grid inside the Viewport2DVisual3D--> 
                <DrawingBrush x:Key="EllipseTile" TileMode="Tile"   
                      Viewport="0 0 0.1 0.1" Stretch="UniformToFill"   > 
                    <DrawingBrush.Drawing> 
                        <GeometryDrawing Brush="Yellow">  
                            <GeometryDrawing.Geometry> 
                                <GeometryGroup> 
                                    <EllipseGeometry RadiusX="20" RadiusY="20"></EllipseGeometry> 
                                </GeometryGroup> 
                            </GeometryDrawing.Geometry> 
                        </GeometryDrawing> 
                    </DrawingBrush.Drawing> 
                </DrawingBrush> 
            </ResourceDictionary> 
     
        </UserControl.Resources> 
     
     
        <Grid Height="Auto" Width="Auto">  
     
            <Border BorderThickness="2" BorderBrush="Black" Margin="6,6,6,5.383">  
     
                <Viewport3D> 
     
                    <Viewport3D.Camera> 
                        <PerspectiveCamera Position="0,0,2.413"/>  
                    </Viewport3D.Camera> 
     
                    <ModelVisual3D> 
                        <ModelVisual3D.Content> 
                            <AmbientLight Color="White" /> 
                        </ModelVisual3D.Content> 
                    </ModelVisual3D> 
     
                    <Viewport2DVisual3D  
                                Geometry="{StaticResource MeshGeometry3D_Plane}"  > 
                        <Viewport2DVisual3D.Transform> 
                            <Transform3DGroup> 
                                <TranslateTransform3D x:Name="imageTranslate" /> 
                            </Transform3DGroup> 
                        </Viewport2DVisual3D.Transform> 
     
                        <Viewport2DVisual3D.Material> 
                            <DiffuseMaterial Viewport2DVisual3D.IsVisualHostMaterial="True" /> 
                        </Viewport2DVisual3D.Material> 
     
                        <!-- NOTE: Using a drawing brush for the background cause the leak.  Using a color does not cause a leak.--> 
                        <Grid Background="{StaticResource EllipseTile}" Width="100" Height="100">  
                            <Grid.Triggers> 
                                <EventTrigger RoutedEvent="Grid.Loaded">  
                                    <BeginStoryboard> 
                                        <Storyboard> 
                                            <DoubleAnimation Name="animateX" 
                                                Storyboard.TargetName="imageTranslate"   
                                                Storyboard.TargetProperty="OffsetX" 
                                                From="1.0" To="-1.0" Duration="0:0:0.3"   
                                                AutoReverse="True" RepeatBehavior="Forever" /> 
                                            <DoubleAnimation Name="animateZ" 
                                                Storyboard.TargetName="imageTranslate"   
                                                Storyboard.TargetProperty="OffsetZ" 
                                                From="2.3" To="-1.0" Duration="0:0:1.37"   
                                                AutoReverse="True" RepeatBehavior="Forever" /> 
                                        </Storyboard> 
                                    </BeginStoryboard> 
                                </EventTrigger> 
                            </Grid.Triggers> 
                        </Grid> 
                    </Viewport2DVisual3D> 
                </Viewport3D> 
            </Border> 
        </Grid> 
     
     
    </UserControl> 
     



     

    Tuesday, September 30, 2008 9:03 AM

Answers

  • This memory leak is definitly caused by the presence of a DrawingBrush.  Removing the drawing brush fixes the problem.  I have not spent the time to typify the all of the scenarios that cause the leak, but I can tell you thatusing a DrawingBrush on a 3D model inside of a Viewport3D or behind a Viewport3D will cause a memory leak on non-Vista OS's.
    Saturday, October 4, 2008 4:59 PM

All replies

  • Can you update driver to the one ATI just released:
     
    http://game.amd.com/us-en/drivers_catalyst.aspx?p=xp/radeonx-xp

    If that doesn't help, please post dxdiag.txt:

    Running dxdiag -> Save All Information and then save the text file.

    Wednesday, October 1, 2008 5:59 AM
  • I also get the same memory leak on my Dell Precision 690 workstation running Windows Server 2003 R2 SP2 and an NVIDIA Quadro NVS 285 (Crappy card).  I will try upgrading to the latest nvidia drivers to see that if fixes that...

    ..Ok, I installed the latest NVIDIA drivers (from 7/18/2008) and the leak is still present.  The memory grew without bound (1+ GB Virtual memory and 700+ MB Peak Working set) and the system became very sluggish after 3 minutes.
    Wednesday, October 1, 2008 8:19 PM
  • I installed the latest ATI drivers for the ATI Radeon HD 3600.  This had no effect on the memory leak. 

    A similar leak issue is also documented at: http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/146f7d3f-2f6f-4d02-98cc-a04202a63b3d

    Thursday, October 2, 2008 2:31 AM
  • This memory leak is definitly caused by the presence of a DrawingBrush.  Removing the drawing brush fixes the problem.  I have not spent the time to typify the all of the scenarios that cause the leak, but I can tell you thatusing a DrawingBrush on a 3D model inside of a Viewport3D or behind a Viewport3D will cause a memory leak on non-Vista OS's.
    Saturday, October 4, 2008 4:59 PM
  • This QFE should fix the issue: http://support.microsoft.com/kb/967634/

    Thanks for reporting the issue.

    Regards

    Gerhard

    Friday, June 12, 2009 12:11 AM