Load SyntaxEditor into memory on application load.

SyntaxEditor for Windows Forms Forum

Posted 17 years ago by Martin Lundberg - Sweden
Version: 4.0.0247
Avatar
Hello!

I'm creating an application which can have multiple SyntaxEditor controls in it. The first time I create a syntaxeditor it takes a lot more then the following creations. The first time takes 1.xx seconds and the folloing one 0.0x seconds (may not be exactly correct but it's a lot faster). I guess that SyntaxEditor is already in memory when I load it the second time. I would like to load SyntaxEditor at starttime without actually adding adding it to my application. So when the user create the first one it's a lot faster.

Sorry if it's a bad explenation but I think you can understand what I mean :)

Thanks in advance!

-Martin


Martin Lundberg Software Developer Sweden

Comments (10)

Posted 17 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
The assembly load time is what you are seeing. If you reference any class in the assembly, it will load the assembly if it is not already loaded. So perhaps just reference the SyntaxEditor type in a variable in your load code and that should load the assembly.


Actipro Software Support

Posted 17 years ago by Martin Lundberg - Sweden
Avatar
I tested it further.

1954ms If I do nothing.
987ms When I add "SyntaxEditor editor;" to my MainForm's constructor.
66ms When I add "SyntaxEDitor editor = new SyntaxEditor()" to my MainForm's constructor.

Now the hit goes when starting the application I guess.


Martin Lundberg Software Developer Sweden

Posted 17 years ago by Kelly Leahy - Software Architect, Milliman
Avatar
That's correct Martin... This hit is incurred when you execute that line of code.

Might I suggest a much lighter weight class to force the assembly load. For instance, TextRange (though this is a "struct" so it may not incur an assembly load - but I think it will). If it doesn't seem to do the trick, try something like ScanIndicatorLayer or one of the other reference types.

Kelly Leahy Software Architect Milliman, USA

Posted 17 years ago by Martin Lundberg - Sweden
Avatar
Hello Kelly!

A nice idea (I had to use a reference type, struct didn't work)! However I found that LicenceManager.Validate also seem to be taking a lot of time the first time it's called (540ms in my case). When doing it your way the assembly load time (a couple of 100ms) is removed but the constructor of first SyntaxEditor still takes 1143ms instead of 75ms if I've already creatd a SyntaxEditor before. When I've already created a SyntaxEditor the LicenseManager.Validate method takes 9ms instead of 540ms.


Martin Lundberg Software Developer Sweden

Posted 17 years ago by Kelly Leahy - Software Architect, Milliman
Avatar
Oh well... I guess it was worth a try. I doubt much else calls LicenseManager.Validate other than the SyntaxEditor itself. I suppose Bill could make a static method available on the SyntaxEditor class that allows you to "prevalidate" the license instead of creating a SyntaxEditor class, but that might be more trouble than it's worth.

Kelly Leahy Software Architect Milliman, USA

Posted 17 years ago by Martin Lundberg - Sweden
Avatar
hehe yeah, thanks for taking time to think about it :) Best thing would be if the loading of the assembly and validation happens after the form is shown. I want the application to start as fast as possible. Well, I'll just test some more when I get home.


Martin Lundberg Software Developer Sweden

Posted 17 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
The only reason that I can think the licensing code would take additional time is if it is loading other assemblies that haven't been loaded as well. My recommendation is for you to breakpoint before creating your first SyntaxEditor class and look at the Visual Studio console to see what has been loaded so far (VS writes debug messages to show as assemblies load) and then step over the SyntaxEditor creation line and again look at the console to see what new has loaded. That will show you what is happening.

I would expect for you to see Shared, WinUICore, and SyntaxEditor assemblies loading at a minimum but maybe others as well.


Actipro Software Support

Posted 17 years ago by Martin Lundberg - Sweden
Avatar
I tested what you said and before The "SyntaxEditor editor = new SyntaxEditor()" line these lines had already been outputed (Plus microsoft assemblies like System.dll, System.Windows.Forms.dll, etc):

'Prototype.vshost.exe' (Managed): Loaded 'C:\Windows\assembly\GAC_MSIL\ActiproSoftware.Shared.Net20\1.0.89.0__36ff2196ab5654b9\ActiproSoftware.Shared.Net20.dll', No symbols loaded.
'Prototype.vshost.exe' (Managed): Loaded 'C:\Windows\assembly\GAC_MSIL\ActiproSoftware.SyntaxEditor.Net20\4.0.246.0__21a821480e210563\ActiproSoftware.SyntaxEditor.Net20.dll', No symbols loaded.
'Prototype.vshost.exe' (Managed): Loaded 'C:\Windows\assembly\GAC_MSIL\ActiproSoftware.WinUICore.Net20\1.0.89.0__1eba893a2bc55de5\ActiproSoftware.WinUICore.Net20.dll', No symbols loaded.

And when I steped paste the line the only thing extra that was outputed was:

'Prototype.vshost.exe' (Managed): Loaded 'C:\Windows\assembly\GAC_MSIL\System.Design\2.0.0.0__b03f5f7f11d50a3a\System.Design.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.

Not sure what we got out of that :) It loaded the assemblies before I first referenced anything from them? But then it's the "No symbols loaded" message.


Martin Lundberg Software Developer Sweden

Posted 17 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
It might be loading the assembly but not hitting the symbols yet and then when you access the SyntaxEditor class, it does hit the symbols and that's what is taking a while. Not sure but that's my best guess. :)


Actipro Software Support

Posted 17 years ago by Martin Lundberg - Sweden
Avatar
Yeah, I'll just make the best of it, it's not that big of a deal :) Thanks both of you for taking time to think about this. It's not really a SyntaxEditor problem but more a general .net problem :) Maybe it's not really a problem depending on who you ask, hehe.


Martin Lundberg Software Developer Sweden

The latest build of this product (v24.1.0) was released 3 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.