I had an answer from another forum.
as long as Frame.Content is not null it's referenced by NavigtionService.
I think you could put that into the category (ahum, cough): "it's not a bug,
it's a feature"
Frame as memory leak but that's normal, so we don't tell our customer!
Seriously, this issue should be mentioned in the documentation, in my app I
have heaps of "unreferenced" Frame reference dangling around, and I was
wondering where from this memory leak come from.
And no: I'm not happy about it, I am not happy I had to research a lot to
find out what the cause and that THIS cause was no where mentionned.
Now I know I should set all my Frame to be
var f = new Frame()
f.Unloaded += (o, e) { f.Content = null; };
to avoid memeory leak, otherwise I will get memory leak.
Now I don't consider acceptable that this is a "known bug" (or so I was
told) which is mentionned nowhere!!!!
(Google "Frame memory leak" doesn't bring up anything)
"Alvin Bruney [ASP.NET MVP]" <vapor dan using hot male spam filter> wrote in
message news:30FE3C40-894F-40D3-8CE7-789F6FC293EE@microsoft.com...
[quoted text, click to view] > It's not necessarily a memory leak if it isn't collected, there may be
> root around depending on the implementation of the object. Here are a
> couple things you can try. Wait around 11 minutes and perform a GC collect
> and then analyze the heap. If it is still around, dump the heap and trace
> the root of the object to see where it is.
>
> --
>
> Regards,
> Alvin Bruney [MVP ASP.NET]
>
> [Shameless Author plug]
> The O.W.C. Black Book, 2nd Edition
> Exclusively on
www.lulu.com/owc $19.99
> -------------------------------------------------------
>
>
> "Lloyd Dupont" <ld@galador.removeme.net> wrote in message
> news:#x5cBlFwIHA.2360@TK2MSFTNGP05.phx.gbl...
>> I have a very simple WPF Application (code inline below).
>> If, as a user, I click "Web Frame" then "Nothing" (then, optionally,
>> "GC.Collect")
>> A Frame object has been created and removed from all hierarchy yet it
>> stays in memory (as a memory profile will tell you).
>>
>> Now, what can I do about that?
>> As my application run, I lose memory from multiple Frame object created
>> dynamically (which are not collected)!!!
>>
>> Worst than that on some of them I navigate to multimedia content and the
>> music keeps playing without way of stopping it!
>>
>> == Window1.xaml ===
>> <Window x:Class="FrameMemLeak.Window1"
>> xmlns="
http://schemas.microsoft.com/winfx/2006/xaml/presentation" >> xmlns:x="
http://schemas.microsoft.com/winfx/2006/xaml" >> Title="Memory Leak in XAML"
>> Height="400" Width="400">
>> <DockPanel>
>> <StackPanel DockPanel.Dock="Left" Orientation="Vertical">
>> <Button Content="Web Frame" Click="OnWebFrame"/>
>> <Button Content="Nothing" Click="OnNothing"/>
>> <Button Content="GC.COllect()" Margin="0,10,0,10" Click="OnCollect"/>
>> </StackPanel>
>> <Border x:Name="carea" BorderThickness="1" BorderBrush="Black" />
>> </DockPanel>
>> </Window>
>> === Windows1.xaml.cs ===
>> public partial class Window1 : Window
>> {
>> public Window1()
>> {
>> InitializeComponent();
>> }
>>
>> private void OnWebFrame(object sender, RoutedEventArgs e)
>> {
>> carea.Child = new Frame() { Source = new
>> Uri("http://www.google.com") };
>> }
>>
>> private void OnNothing(object sender, RoutedEventArgs e)
>> {
>> carea.Child = null;
>> }
>>
>> private void OnCollect(object sender, RoutedEventArgs e)
>> {
>> GC.Collect();
>> }
>> }
>> ================
>