• R/O
  • HTTP
  • SSH
  • HTTPS

FooEditEngine: Commit


Commit MetaInfo

Revision010f7f8a8f99e6c85b53f32322e1879bfda5471b (tree)
Time2021-01-06 00:40:29
Authortest <test@yaho...>
Commitertest

Log Message

ドキュメントをクリアしたときにメモリーを開放するようにした

Change Summary

Incremental Difference

--- a/Core/Document.cs
+++ b/Core/Document.cs
@@ -1116,6 +1116,8 @@ namespace FooEditEngine
11161116 public void Clear()
11171117 {
11181118 this.buffer.Clear();
1119+ System.Runtime.GCSettings.LargeObjectHeapCompactionMode = System.Runtime.GCLargeObjectHeapCompactionMode.CompactOnce;
1120+ GC.Collect();
11191121 this.Dirty = false;
11201122 }
11211123
--- a/Core/GapBuffer.cs
+++ b/Core/GapBuffer.cs
@@ -34,7 +34,7 @@ namespace Slusser.Collections.Generic
3434 {
3535 #region Fields
3636
37- private const int MIN_CAPACITY = 4;
37+ private const int MIN_CAPACITY = 128;
3838
3939 private T[] _buffer;
4040 private int _gapStart;
@@ -710,7 +710,7 @@ namespace Slusser.Collections.Generic
710710 if (required > (this._gapEnd - this._gapStart))
711711 {
712712 // Calculate a new size (double the size necessary)
713- int newCapacity = (Count + required) * 2;
713+ int newCapacity = Count + required + MIN_CAPACITY;
714714 if (newCapacity < MIN_CAPACITY)
715715 newCapacity = MIN_CAPACITY;
716716
--- a/Core/StringBuffer.cs
+++ b/Core/StringBuffer.cs
@@ -234,6 +234,7 @@ namespace FooEditEngine
234234 internal void Clear()
235235 {
236236 this.buf.Clear();
237+ this.buf.TrimExcess();
237238 this.Update(this, new DocumentUpdateEventArgs(UpdateType.Clear, 0, this.buf.Count, 0));
238239 }
239240
--- a/WPF/Test/MainWindow.xaml.cs
+++ b/WPF/Test/MainWindow.xaml.cs
@@ -124,7 +124,11 @@ namespace Test
124124 if (result == true)
125125 {
126126 this.fooTextBox.IsEnabled = false;
127- await this.fooTextBox.LoadFileAsync(ofd.FileName, Encoding.Default,this.cancleTokenSrc);
127+ System.IO.FileStream file = System.IO.File.Open(ofd.FileName,System.IO.FileMode.Open);
128+ System.IO.StreamReader sr = new System.IO.StreamReader(file, Encoding.Default);
129+ await this.fooTextBox.Document.LoadAsync(sr, this.cancleTokenSrc, (int)file.Length);
130+ sr.Close();
131+ file.Close();
128132 this.fooTextBox.IsEnabled = true;
129133 this.fooTextBox.Refresh();
130134 }
Show on old repository browser