Memory leak using Interaction Triggers on loaded event with MVVM light

Doing the following causes a memory leak and means the page that it appears on is not garbage collected:

<i:Interaction.Triggers>
<i:EventTrigger EventName="Loaded">
<ex:EventToCommand Command="{Binding LoadedCommand}" />
</i:EventTrigger>
</i:Interaction.Triggers>

I found this whilst doing some WP7 development, using the normal Loaded event does not cause an issue. It is detectable by calling GC.Collect() on the destination page and checking to see if the finlize of the previous page is called. I found the finalizer was called N times only when I quit the app (where N is the number of times I had navigated to the page).

Since the phone apps are torn down if they exceed 90MB it’s a bit more noticeable.

Advertisements

One thought on “Memory leak using Interaction Triggers on loaded event with MVVM light

  1. Pingback: WP7 Detecting Memory Leaks « Simon Ransom's space

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s