Revision | 010f7f8a8f99e6c85b53f32322e1879bfda5471b (tree) |
---|---|
Time | 2021-01-06 00:40:29 |
Author | test <test@yaho...> |
Commiter | test |
ドキュメントをクリアしたときにメモリーを開放するようにした
@@ -1116,6 +1116,8 @@ namespace FooEditEngine | ||
1116 | 1116 | public void Clear() |
1117 | 1117 | { |
1118 | 1118 | this.buffer.Clear(); |
1119 | + System.Runtime.GCSettings.LargeObjectHeapCompactionMode = System.Runtime.GCLargeObjectHeapCompactionMode.CompactOnce; | |
1120 | + GC.Collect(); | |
1119 | 1121 | this.Dirty = false; |
1120 | 1122 | } |
1121 | 1123 |
@@ -34,7 +34,7 @@ namespace Slusser.Collections.Generic | ||
34 | 34 | { |
35 | 35 | #region Fields |
36 | 36 | |
37 | - private const int MIN_CAPACITY = 4; | |
37 | + private const int MIN_CAPACITY = 128; | |
38 | 38 | |
39 | 39 | private T[] _buffer; |
40 | 40 | private int _gapStart; |
@@ -710,7 +710,7 @@ namespace Slusser.Collections.Generic | ||
710 | 710 | if (required > (this._gapEnd - this._gapStart)) |
711 | 711 | { |
712 | 712 | // Calculate a new size (double the size necessary) |
713 | - int newCapacity = (Count + required) * 2; | |
713 | + int newCapacity = Count + required + MIN_CAPACITY; | |
714 | 714 | if (newCapacity < MIN_CAPACITY) |
715 | 715 | newCapacity = MIN_CAPACITY; |
716 | 716 |
@@ -234,6 +234,7 @@ namespace FooEditEngine | ||
234 | 234 | internal void Clear() |
235 | 235 | { |
236 | 236 | this.buf.Clear(); |
237 | + this.buf.TrimExcess(); | |
237 | 238 | this.Update(this, new DocumentUpdateEventArgs(UpdateType.Clear, 0, this.buf.Count, 0)); |
238 | 239 | } |
239 | 240 |
@@ -124,7 +124,11 @@ namespace Test | ||
124 | 124 | if (result == true) |
125 | 125 | { |
126 | 126 | 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(); | |
128 | 132 | this.fooTextBox.IsEnabled = true; |
129 | 133 | this.fooTextBox.Refresh(); |
130 | 134 | } |