View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0001707 | NoesisGUI | C++ SDK | public | 2020-05-28 11:37 | 2020-09-24 16:38 |
| Reporter | steveh | Assigned To | jsantos | ||
| Priority | normal | Severity | feature | ||
| Status | assigned | Resolution | open | ||
| Product Version | 3.0 | ||||
| Target Version | 3.0 | ||||
| Summary | 0001707: Feature request: Identify and notify the user about cyclic references | ||||
| Description | Hi guys, I've recently been looking at cleaning up our shutdown code and I've fixed a few issues where a child holds a ref counted pointer to a parent object in the hierarchy. This ultimately creates a cyclic dependency between the two objects and prevents them from being cleaned up. I've attached 2 examples of code which might do this, the first is setting a DataContext to a parent object, and another is setting the TargetName on a GoToStateAction to a parent object. It would be extremely helpful to try and detect these cases. Perhaps in debug you could assert if the TargetName or DataContext are trying to be set to a parent object in the hierarchy when you set the pointer. Or perhaps a better way is to try and find these cyclic references in shutdown if we've detected that we've leaked memory. Essentially any further information to help track these issues down would be extremely beneficial! Cheers. | ||||
| Steps To Reproduce |
| ||||
| Attached Files | DataContext.xaml (571 bytes)
<Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Name="RootGrid" Background="red" width="100" height="100">
<!-- This DataContext takes a ref counted pointer to the grid and creates a cyclic depdency -->
<Border x:Name="Border" DataContext="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Grid}}}">
<TextBlock x:Name="TextBlock" Text="{Binding Name}" VerticalAlignment="Center" HorizontalAlignment="Center" />
</Border>
</Grid> GoToStateAction.xaml (1,489 bytes)
<Grid
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
x:Name="RootGrid" Background="Red">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal"/>
<VisualState x:Name="Checked">
<Storyboard>
<ColorAnimation Storyboard.TargetName="RootGrid" Storyboard.TargetProperty="Background.Color" To="Green"/>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Checkbox x:Name="Checkbox" />
<Border>
<i:Interaction.Triggers>
<ei:DataTrigger Binding="{Binding ElementName=Checkbox, Path=IsChecked}" Value="True">
<!-- This GoToStateAction will create a cyclic dependency as it takes a ref counted pointer to RootGrid -->
<ei:GoToStateAction StateName="Checked" TargetName="RootGrid" />
</ei:DataTrigger>
<ei:DataTrigger Binding="{Binding ElementName=Checkbox, Path=IsChecked}" Value="False">
<ei:GoToStateAction StateName="Normal" TargetName="RootGrid" />
</ei:DataTrigger>
</i:Interaction.Triggers>
</Border>
</Grid> | ||||
| Platform | Any | ||||
| related to | 0001706 | resolved | sfernandez | Memory leak when binding DataContext to parent user control |
| related to | 0001798 | resolved | sfernandez | Memory leak when using ContextMenuService.PlacementTarget |
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2020-05-28 11:37 | steveh | New Issue | |
| 2020-05-28 11:37 | steveh | File Added: DataContext.xaml | |
| 2020-05-28 11:37 | steveh | File Added: GoToStateAction.xaml | |
| 2020-05-28 19:08 | sfernandez | Relationship added | related to 0001706 |
| 2020-06-08 14:02 | jsantos | Assigned To | => jsantos |
| 2020-06-08 14:02 | jsantos | Status | new => assigned |
| 2020-06-08 14:04 | jsantos | Note Added: 0006428 | |
| 2020-06-08 14:04 | jsantos | Target Version | => 3.0 |
| 2020-06-08 14:04 | jsantos | Description Updated | |
| 2020-06-08 14:04 | jsantos | Steps to Reproduce Updated | |
| 2020-06-08 14:05 | jsantos | Note Edited: 0006428 | |
| 2020-06-08 14:05 | jsantos | Note Edited: 0006428 | |
| 2020-09-24 16:38 | sfernandez | Relationship added | related to 0001798 |