Hello,
I'm investigating some memory related issues in our product with Scitech memory profiler and I noticed a memory leak in the view where we're using the RadMap control.
The event handler for Telerik.Windows.Controls.RadMap.ProvidersCollectionChanged( object,<Unknown> ) is not properly removed and each time the view containing the control is navigated to, a set of new instances of other controls are created which are never released.
Can you provide some help on this?
I'm investigating some memory related issues in our product with Scitech memory profiler and I noticed a memory leak in the view where we're using the RadMap control.
The event handler for Telerik.Windows.Controls.RadMap.ProvidersCollectionChanged( object,<Unknown> ) is not properly removed and each time the view containing the control is navigated to, a set of new instances of other controls are created which are never released.
Can you provide some help on this?
3 Answers, 1 is accepted
0
Hello Mihai,
It is very complicated and it is hard to reproduce the problem without your solution, but using just the description you sent. Could you, please, provide us with your solution or with a small sample solution which reproduces it?
Greetings,
Andrey Murzov
the Telerik team
It is very complicated and it is hard to reproduce the problem without your solution, but using just the description you sent. Could you, please, provide us with your solution or with a small sample solution which reproduces it?
Greetings,
Andrey Murzov
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
0
Mihai
Top achievements
Rank 1
answered on 04 Apr 2013, 07:57 AM
Hi,
Hopefully this can be a bit more helpful.
The RadMap control is used within our view is depicted in the xaml extract below. This is placed directly in a grid which is the root layout for our view.
The InitializeMapBehavior looks like this:
When I enter and leave this view and I take a snapshot of the memory each time, the number of instances of a control which is used several times in the same grid increases steadily and they are never released. Apparently RadMap can not be collected and since it holds a reference to its parent, nothing can be collected.
From the instance graph and call stack I'd guess that subscriber(s) to ProvidersCollectionChanged do not unsubscribe, hence the reference is kept.
Please have a look at the instance graph snapshots I attached and below is the call stack for the event handler in RadMap02.PNG.
Thank you,
Mihai
Telerik.Windows.Controls.RadMap.ProvidersCollectionChanged( object,<Unknown> )
System.Windows.DependencyObjectCollection<T>.TryCollectionChanged( NotifyCollectionChangedEventArgs )
System.Windows.DependencyObjectCollection<T>.RaiseCollectionChanged( NotifyCollectionChangedAction,object,int )
System.Windows.DependencyObjectCollection<T>.Insert( int,T )
Telerik.Windows.Controls.RadMap.ProviderChanged( <Unknown>,<Unknown> )
Telerik.Windows.PropertyMetadata.PropertyChangeHook.OnPropertyChanged( <Unknown>,<Unknown> )
System.Windows.DependencyObject.RaisePropertyChangeNotifications( DependencyProperty,object,object )
System.Windows.DependencyObject.UpdateEffectiveValue( DependencyProperty,EffectiveValueEntry,ref EffectiveValueEntry,ValueOperation )
System.Windows.DependencyObject.SetValueInternal( DependencyProperty,object,bool,bool )
System.Windows.DependencyObject.SetValueInternal( DependencyProperty,object )
System.Windows.DependencyObject.SetValue( DependencyProperty,object )
Telerik.Windows.Controls.RadMap.set_Provider( MapProviderBase )
CoreSystems.Infrastructure.Silverlight.Common.UI.Views.Addresses.Behaviors.InitializeMapBehavior.OnAttached()
System.Windows.Interactivity.Behavior.Attach( <Unknown> )
System.Windows.Interactivity.BehaviorCollection.ItemAdded( Behavior )
System.Windows.Interactivity.AttachableCollection<T>.OnCollectionChanged( object,<Unknown> )
System.Windows.DependencyObjectCollection<T>.TryCollectionChanged( NotifyCollectionChangedEventArgs )
System.Windows.DependencyObjectCollection<T>.RaiseCollectionChanged( NotifyCollectionChangedAction,object,int )
System.Windows.DependencyObjectCollection<T>.System.Collections.IList.Add( object )
MS.Internal.XamlManagedRuntimeRPInvokes.Add( ref XamlQualifiedObject,XamlPropertyToken,ref XamlQualifiedObject )
[Native to managed transition]
[Managed to native transition]
MS.Internal.XcpImports.Application_LoadComponentNative( IntPtr,IntPtr,uint,string,uint,byte*,uint,string )
MS.Internal.XcpImports.Application_LoadComponent( IManagedPeerBase,string,<Unknown>,uint,string )
System.Windows.Application.LoadComponent( object,<Unknown> )
[Truncated]
Hopefully this can be a bit more helpful.
The RadMap control is used within our view is depicted in the xaml extract below. This is placed directly in a grid which is the root layout for our view.
<
telerik:RadMap
Grid.Row
=
"0"
Center
=
"{Binding PersonLocation}"
ZoomLevel
=
"1"
DistanceUnit
=
"Kilometer"
x:Name
=
"map"
>
<
i:Interaction.Behaviors
>
<
behaviors4:InitializeMapBehavior
/>
<
n:BoolValueVisibilityBehavior
Value
=
"{Binding ShowPersonLocation}"
/>
<
behaviors3:SetCurrentUiThreadLanguageBehavior
/>
</
i:Interaction.Behaviors
>
The InitializeMapBehavior looks like this:
public
class
InitializeMapBehavior : Behavior<RadMap>
{
protected
override
void
OnAttached()
{
base
.OnAttached();
var map =
this
.AssociatedObject;
map.Provider =
new
BingMapProvider(MapMode.Road,
true
, BingMapCredentialsWrapper.ApiKey);
}
}
When I enter and leave this view and I take a snapshot of the memory each time, the number of instances of a control which is used several times in the same grid increases steadily and they are never released. Apparently RadMap can not be collected and since it holds a reference to its parent, nothing can be collected.
From the instance graph and call stack I'd guess that subscriber(s) to ProvidersCollectionChanged do not unsubscribe, hence the reference is kept.
Please have a look at the instance graph snapshots I attached and below is the call stack for the event handler in RadMap02.PNG.
Thank you,
Mihai
Telerik.Windows.Controls.RadMap.ProvidersCollectionChanged( object,<Unknown> )
System.Windows.DependencyObjectCollection<T>.TryCollectionChanged( NotifyCollectionChangedEventArgs )
System.Windows.DependencyObjectCollection<T>.RaiseCollectionChanged( NotifyCollectionChangedAction,object,int )
System.Windows.DependencyObjectCollection<T>.Insert( int,T )
Telerik.Windows.Controls.RadMap.ProviderChanged( <Unknown>,<Unknown> )
Telerik.Windows.PropertyMetadata.PropertyChangeHook.OnPropertyChanged( <Unknown>,<Unknown> )
System.Windows.DependencyObject.RaisePropertyChangeNotifications( DependencyProperty,object,object )
System.Windows.DependencyObject.UpdateEffectiveValue( DependencyProperty,EffectiveValueEntry,ref EffectiveValueEntry,ValueOperation )
System.Windows.DependencyObject.SetValueInternal( DependencyProperty,object,bool,bool )
System.Windows.DependencyObject.SetValueInternal( DependencyProperty,object )
System.Windows.DependencyObject.SetValue( DependencyProperty,object )
Telerik.Windows.Controls.RadMap.set_Provider( MapProviderBase )
CoreSystems.Infrastructure.Silverlight.Common.UI.Views.Addresses.Behaviors.InitializeMapBehavior.OnAttached()
System.Windows.Interactivity.Behavior.Attach( <Unknown> )
System.Windows.Interactivity.BehaviorCollection.ItemAdded( Behavior )
System.Windows.Interactivity.AttachableCollection<T>.OnCollectionChanged( object,<Unknown> )
System.Windows.DependencyObjectCollection<T>.TryCollectionChanged( NotifyCollectionChangedEventArgs )
System.Windows.DependencyObjectCollection<T>.RaiseCollectionChanged( NotifyCollectionChangedAction,object,int )
System.Windows.DependencyObjectCollection<T>.System.Collections.IList.Add( object )
MS.Internal.XamlManagedRuntimeRPInvokes.Add( ref XamlQualifiedObject,XamlPropertyToken,ref XamlQualifiedObject )
[Native to managed transition]
[Managed to native transition]
MS.Internal.XcpImports.Application_LoadComponentNative( IntPtr,IntPtr,uint,string,uint,byte*,uint,string )
MS.Internal.XcpImports.Application_LoadComponent( IManagedPeerBase,string,<Unknown>,uint,string )
System.Windows.Application.LoadComponent( object,<Unknown> )
[Truncated]
0
Hello Mihai,
The RadMap control contains the Dispose method. You can invoke it for disposing all resources which are used by RadMap control.
Kind regards,
Andrey Murzov
the Telerik team
The RadMap control contains the Dispose method. You can invoke it for disposing all resources which are used by RadMap control.
Kind regards,
Andrey Murzov
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.