Optimization suggestion regarding Document objects?

SyntaxEditor for Windows Forms Forum

Posted 13 years ago by Jeff Cohen
Version: 4.0.0233
Avatar
My app will probably allow the user to have multiple documents open at once (or seemingly at once) with a typical tabbed interface.

I read in the docs that I should create one Language instance per type, and reuse the language instances across all SyntaxEditor objects that need them.

I'm wondering also, is it suggested to keep a separate list of Document objects, say one per open file, and assign the SyntaxEditor.Document property on the fly? In other words, I'd have only one SyntaxEditor object in the application, but one Document object per tab; and then I would set the SyntaxEditor.Document property when a tab is selected?

Or is having many SyntaxEditor objects usually not that much of a worry?

I'm planning on trying it both ways and watching the memory usage in Task Manager, but I was wondering if there's any rule of thumb based on previous experience?

Thanks!
Jeff

Comments (1)

Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Jeff,

Yes reusing language instances as you said is highly recommended.

What you said about storing Documents is a good way to conserve memory too. If you only ever show one SyntaxEditor at any time then swapping in a Document is a perfectly good way to do it. It will retain undo/redo history, modification marks, and all the other document-related state goodies that way.

Having more SyntaxEditor controls will raise memory. As to the degree, it depends on what features you have on. For instance, it has to keep track of character widths and display lines in certain scenarios.

If you want to cut down on memory even more, just store the text of each document with it is swapped out and set that back to the main Document when it becomes active again. Of course in this way, you lose your undo/redo history and those other document state features.


Actipro Software Support

The latest build of this product (v2018.1 build 0342) was released 11 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.