Posted 19 years ago
by Adam Dickinson

In SyntaxEditor 3.1.203 .NET 1.1 Visual Studio 2003:
I have a multiply-tabbed application that creates a SyntaxEditor for each document loaded. I have routines that parse the language and create 2 LexicalPatternGroups and fills each of them with LexicalPatterns. The language gets updated at run-time as new syntax keywords are created by the user.
I get a large memory leak when I update with the following method:
1) Find my 2 LexicalPatternGroups and if found, remove them from the "DefaultState" LexicalState's pattern groups. (I even tried calling a Clear() and a Dispose() but still a large leak)
2) Create 2 new LexicalPatternGroups and add them to the LexicalState's pattern groups.
3) Create new LexicalPatterns and add them to the appropriate group.
I get a smaller memory leak when I update this way:
1) Find my 2 LexicalPatternGroups, and if found, clear them. Otherwise, create them.
2) Create new LexicalPatterns and add them to the appropriate group.
I get no memory leak when I update this way:
1) Create a cache of LexicalPatterns.
1) Find my 2 LexicalPatternGroups, and if found, clear them. Otherwise, create them.
2) Add the appropriate LexicalPattern from the cache to the appropriate group.
This last method is great because it saves a lot of memory, avoids the apparent memory leaks, and saves some processing time. However, I have problems if I ever need to reload the file (if it is changed outside of my editor).I prompt the user to reload the modified file, and the catch is that LoadFile won't fail unless I have 2 prompts open and you choose to reload on the 2nd prompt.
So… memory leak: real or no?
Proper way to dynamically alter the language at run-time?
Anything special I need to be aware of when reloading a file, in general?
[Modified at 05/25/2006 04:00 PM]
I have a multiply-tabbed application that creates a SyntaxEditor for each document loaded. I have routines that parse the language and create 2 LexicalPatternGroups and fills each of them with LexicalPatterns. The language gets updated at run-time as new syntax keywords are created by the user.
I get a large memory leak when I update with the following method:
1) Find my 2 LexicalPatternGroups and if found, remove them from the "DefaultState" LexicalState's pattern groups. (I even tried calling a Clear() and a Dispose() but still a large leak)
2) Create 2 new LexicalPatternGroups and add them to the LexicalState's pattern groups.
3) Create new LexicalPatterns and add them to the appropriate group.
I get a smaller memory leak when I update this way:
1) Find my 2 LexicalPatternGroups, and if found, clear them. Otherwise, create them.
2) Create new LexicalPatterns and add them to the appropriate group.
I get no memory leak when I update this way:
1) Create a cache of LexicalPatterns.
1) Find my 2 LexicalPatternGroups, and if found, clear them. Otherwise, create them.
2) Add the appropriate LexicalPattern from the cache to the appropriate group.
This last method is great because it saves a lot of memory, avoids the apparent memory leaks, and saves some processing time. However, I have problems if I ever need to reload the file (if it is changed outside of my editor).
Object reference not set to an instance of an object:
at ActiproSoftware.SyntaxEditor.LexicalState._1(StringBuilder , Int32& , Int32 , LexicalPattern& )
at _23._1(SyntaxLanguage , StringBuilder , Int32& , Int32 , _22 , Token , Int32 )
at ActiproSoftware.SyntaxEditor.Document._1(DocumentModification )
at ActiproSoftware.SyntaxEditor.Document.set_Text(String value)
at ActiproSoftware.SyntaxEditor.Document.LoadFile(String path)
So… memory leak: real or no?
Proper way to dynamically alter the language at run-time?
Anything special I need to be aware of when reloading a file, in general?
[Modified at 05/25/2006 04:00 PM]