diff --git a/MdXaml.sln b/MdXaml.sln
index 4f74420..b847c9a 100644
--- a/MdXaml.sln
+++ b/MdXaml.sln
@@ -34,7 +34,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MdXaml.Plugins", "MdXaml.Pl
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MdXaml.AnimatedGif", "MdXaml.AnimatedGif\MdXaml.AnimatedGif.csproj", "{A7666AD6-CB44-4399-AC61-05DE80D65F9D}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MdXaml.Full", "MdXaml.Full\MdXaml.Full.csproj", "{0ABF174B-B7EA-4225-BB56-5A6E8C011CFB}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MdXaml.Full", "MdXaml.Full\MdXaml.Full.csproj", "{0ABF174B-B7EA-4225-BB56-5A6E8C011CFB}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CheckMemoryLeak", "samples\CheckMemoryLeak\CheckMemoryLeak.csproj", "{CC0EBCF6-0EE9-4873-BB6F-6A9F4CF84B79}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -90,6 +92,10 @@ Global
{0ABF174B-B7EA-4225-BB56-5A6E8C011CFB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0ABF174B-B7EA-4225-BB56-5A6E8C011CFB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0ABF174B-B7EA-4225-BB56-5A6E8C011CFB}.Release|Any CPU.Build.0 = Release|Any CPU
+ {CC0EBCF6-0EE9-4873-BB6F-6A9F4CF84B79}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {CC0EBCF6-0EE9-4873-BB6F-6A9F4CF84B79}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {CC0EBCF6-0EE9-4873-BB6F-6A9F4CF84B79}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {CC0EBCF6-0EE9-4873-BB6F-6A9F4CF84B79}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -101,6 +107,7 @@ Global
{C539C7B4-BBF2-4AC2-A732-0C47E125CCD2} = {435867FA-EE25-4708-9BBA-8509ABC7E389}
{C45A1400-B4E9-4638-BF1F-4BB38CEC5E93} = {09BEAB2A-F47E-4D2B-AE81-8DC1BBB52638}
{CEF2B49F-90AF-4B65-AA0C-A12AB1C0A18F} = {09BEAB2A-F47E-4D2B-AE81-8DC1BBB52638}
+ {CC0EBCF6-0EE9-4873-BB6F-6A9F4CF84B79} = {435867FA-EE25-4708-9BBA-8509ABC7E389}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {23DF7019-3B25-4B82-8955-25F1DDD72D84}
diff --git a/samples/CheckMemoryLeak/App.xaml b/samples/CheckMemoryLeak/App.xaml
new file mode 100644
index 0000000..12f8eaf
--- /dev/null
+++ b/samples/CheckMemoryLeak/App.xaml
@@ -0,0 +1,9 @@
+
+
+
+
+
diff --git a/samples/CheckMemoryLeak/App.xaml.cs b/samples/CheckMemoryLeak/App.xaml.cs
new file mode 100644
index 0000000..07d3145
--- /dev/null
+++ b/samples/CheckMemoryLeak/App.xaml.cs
@@ -0,0 +1,14 @@
+using System.Configuration;
+using System.Data;
+using System.Windows;
+
+namespace CheckMemoryLeak
+{
+ ///
+ /// Interaction logic for App.xaml
+ ///
+ public partial class App : Application
+ {
+ }
+
+}
diff --git a/samples/CheckMemoryLeak/AssemblyInfo.cs b/samples/CheckMemoryLeak/AssemblyInfo.cs
new file mode 100644
index 0000000..b0ec827
--- /dev/null
+++ b/samples/CheckMemoryLeak/AssemblyInfo.cs
@@ -0,0 +1,10 @@
+using System.Windows;
+
+[assembly: ThemeInfo(
+ ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
+ //(used if a resource is not found in the page,
+ // or application resource dictionaries)
+ ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
+ //(used if a resource is not found in the page,
+ // app, or any theme specific resource dictionaries)
+)]
diff --git a/samples/CheckMemoryLeak/CheckMemoryLeak.csproj b/samples/CheckMemoryLeak/CheckMemoryLeak.csproj
new file mode 100644
index 0000000..4f583ed
--- /dev/null
+++ b/samples/CheckMemoryLeak/CheckMemoryLeak.csproj
@@ -0,0 +1,16 @@
+
+
+
+ WinExe
+ $(SampleTargetFrameworks)
+ enable
+ true
+ False
+ 9
+
+
+
+
+
+
+
diff --git a/samples/CheckMemoryLeak/MainWindow.xaml b/samples/CheckMemoryLeak/MainWindow.xaml
new file mode 100644
index 0000000..c4c199d
--- /dev/null
+++ b/samples/CheckMemoryLeak/MainWindow.xaml
@@ -0,0 +1,52 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/samples/CheckMemoryLeak/MainWindow.xaml.cs b/samples/CheckMemoryLeak/MainWindow.xaml.cs
new file mode 100644
index 0000000..07d1481
--- /dev/null
+++ b/samples/CheckMemoryLeak/MainWindow.xaml.cs
@@ -0,0 +1,51 @@
+using MdXaml.Full;
+using System;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace CheckMemoryLeak
+{
+ ///
+ /// Interaction logic for MainWindow.xaml
+ ///
+ public partial class MainWindow : Window
+ {
+ public MainWindow()
+ {
+ InitializeComponent();
+ }
+
+ private async void Button_Click(object sender, RoutedEventArgs e)
+ {
+ var vm = (MainWindowViewModel)DataContext;
+ foreach (var content in vm.Contents)
+ {
+ var viewer = new MarkdownScrollViewer();
+
+ if (content.ContentType == ContentType.Resource)
+ {
+ viewer.Source = new Uri(content.Text);
+ }
+ if (content.ContentType == ContentType.Text)
+ {
+ viewer.Markdown = content.Text;
+ }
+
+ ViewPanel.Children.Add(viewer);
+
+ while (!viewer.IsLoaded)
+ await Task.Delay(1000);
+
+ await Task.Delay(1000);
+
+ ViewPanel.Children.Clear();
+ }
+
+ foreach (var i in Enumerable.Range(0, 10)) {
+ GC.Collect();
+ await Task.Delay(1000);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/samples/CheckMemoryLeak/MainWindowViewModel.cs b/samples/CheckMemoryLeak/MainWindowViewModel.cs
new file mode 100644
index 0000000..07a8143
--- /dev/null
+++ b/samples/CheckMemoryLeak/MainWindowViewModel.cs
@@ -0,0 +1,75 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Data;
+using System.Net.Mime;
+using System.Text;
+using System.Windows.Input;
+
+namespace CheckMemoryLeak
+{
+ internal class MainWindowViewModel
+ {
+ public ICommand AddTextCommand { get; }
+ public ICommand AddResourceCommand { get; }
+
+ public ObservableCollection Contents { get; }
+ public MainWindowViewModel()
+ {
+ Contents = new();
+ AddTextCommand = new DelegateCommand(AddText);
+ AddResourceCommand = new DelegateCommand(AddResource);
+
+ Contents.Add(new Content(ContentType.Resource) { Text = "https://raw.githubusercontent.com/whistyun/MdXaml/master/samples/MdXaml.Demo/MainWindow.md#note" });
+ Contents.Add(new Content(ContentType.Resource) { Text = @"file:///D:\MdXaml\samples\MdXaml.Demo\MainWindow.md#note" });
+ Contents.Add(new Content(ContentType.Text) { Text = @"[text](file:///D:\MdXaml\samples\MdXaml.Demo\MainWindow.md#note)" });
+ }
+
+ public void AddText()
+ {
+ Contents.Add(new Content(ContentType.Text));
+ }
+ public void AddResource()
+ {
+ Contents.Add(new Content(ContentType.Resource));
+ }
+ }
+
+ public class DelegateCommand : ICommand
+ {
+ private Action _action;
+ public event EventHandler? CanExecuteChanged;
+
+ public DelegateCommand(Action act)
+ {
+ _action = act;
+ }
+
+ public bool CanExecute(object? parameter)
+ {
+ return true;
+ }
+
+ public void Execute(object? parameter)
+ {
+ _action();
+ }
+ }
+
+ public class Content
+ {
+ public ContentType ContentType { get; }
+ public string Text { get; set; }
+
+ public Content(ContentType type)
+ {
+ ContentType = type;
+ }
+ }
+
+ public enum ContentType
+ {
+ Resource,
+ Text
+ }
+}