Posted 15 years ago
by Matt Whitfield
Version: 4.0.0280
Platform: .NET 2.0
Environment: Windows XP (32-bit)
Ok, hopefully this one has an easy fix. In my app I construct DynamicSyntaxLanguage objects in another thread and apply them to the SyntaxEditor.Document when it's ready. Unfortunately this has two nasty side effects - 1) it gets progressively slower over time and 2) it leaks (a lot).
This is code in the MainForm.cs of the VS2008 sample application that comes with .280 -
Is there something I'm missing?
This is code in the MainForm.cs of the VS2008 sample application that comes with .280 -
// does not leak
private void helpAboutMenuItem_Click(object sender, System.EventArgs e) {
for (int i = 0; i < 20; i++)
{
editor.Document.LoadLanguageFromXml(@"C:\Program Files\Actipro Software\WindowsForms\SyntaxEditor\v4.0.0280\TestApplication-CSharp.VS2008\Languages\Dynamic\Lexers\ActiproSoftware.SQL.xml", 0);
DynamicSyntaxLanguage dsl = editor.Document.Language as DynamicSyntaxLanguage;
DynamicLexicalState dls = dsl.LexicalStates[0] as DynamicLexicalState;
LexicalPatternGroup lpg = dls.LexicalPatternGroups[0];
for (int j = 0; j < 1000; j++)
{
lpg.Add(new LexicalPattern(j.ToString()));
}
}
}
// leaks
private void helpAboutMenuItem_Click(object sender, System.EventArgs e) {
for (int i = 0; i < 20; i++)
{
DynamicSyntaxLanguage dsl = DynamicSyntaxLanguage.LoadFromXml(@"C:\Program Files\Actipro Software\WindowsForms\SyntaxEditor\v4.0.0280\TestApplication-CSharp.VS2008\Languages\Dynamic\Lexers\ActiproSoftware.SQL.xml", 0);
DynamicLexicalState dls = dsl.LexicalStates[0] as DynamicLexicalState;
LexicalPatternGroup lpg = dls.LexicalPatternGroups[0];
for (int j = 0; j < 1000; j++)
{
lpg.Add(new LexicalPattern(j.ToString()));
}
editor.Document.Language = dsl;
}
}
// leaks (less)
private void helpAboutMenuItem_Click(object sender, System.EventArgs e) {
for (int i = 0; i < 20; i++)
{
editor.Document.LoadLanguageFromXml(@"C:\Program Files\Actipro Software\WindowsForms\SyntaxEditor\v4.0.0280\TestApplication-CSharp.VS2008\Languages\Dynamic\Lexers\ActiproSoftware.SQL.xml", 0);
DynamicSyntaxLanguage dsl = editor.Document.Language as DynamicSyntaxLanguage;
dsl.IsUpdating = true;
DynamicLexicalState dls = dsl.LexicalStates[0] as DynamicLexicalState;
LexicalPatternGroup lpg = dls.LexicalPatternGroups[0];
for (int j = 0; j < 1000; j++)
{
lpg.Add(new LexicalPattern(j.ToString()));
}
dsl.IsUpdating = false;
}
}