icsharpcode / AvalonEdit

The WPF-based text editor component used in SharpDevelop
http://avalonedit.net/
MIT License
1.85k stars 469 forks source link

Memeory Issue: Two many objects cannot be collected by GC #405

Closed sinotaotao closed 1 year ago

sinotaotao commented 1 year ago

In my program, after set Text attribute of a AvalonTextEditor with a string that has 1,000,000 lines, set Text to EMPTY again, I found a Memory problem. It seems too many objects are not GC.Collect.

Even set TextEditor variable to null is no help. The huge memory must be freeed after the process exits.

It seems we cannot clear Document.Lines, which is a list of DocumentLine type.

So, the problem is how to free memory after a big document closed?

image

sinotaotao commented 1 year ago

I think the problem is same with https://github.com/icsharpcode/AvalonEdit/issues/386

asign a new documet to Editor object is no help, too.

textEditor.Document = new Avalon.Document.TextDocument(value);

sinotaotao commented 1 year ago

UPDATE: Objects mentioned in the first post could be collected by GC, and its count is correct on my another computer. The computer which has memory problem was send to maintaince. After some tests, I found the TASKMGR lists the app with a big memory value. the objects with most memeoy used value is TlsOverPerCoreLockedStacksArrayPool. Maybe process take some memory for pool to improve performance, so this is not a problem.