I've written a
VB.NET Windows based application that runs full time on several machines. It acts like a time clock, collecting information on when employees arrive at and leave work. It consists of a login screen which is always displayed when the program is not being used, and other screens that are only loaded when necessary.
On occasion, when the program has not been used for a while, it takes as much as 30 seconds to load the second screen displayed once the user clears the login screen. As the time an employee arrives at work effects when they may leave, this delay is causing concern amongst employees who queue up to sign in for the day because they may have to work a whole minute longer (gasp!).
I believe this delay is related to garbage collection - either GC is running when this delay occurs and the program is getting insufficient CPU to load the next form, or the form has to be run through the JIT again because the last instance was disposed. I may be mistaken on the last statement, as I was thinking that perhaps if an object was disposed but not cleand up, it could be re-used without recompiling and .NET may nto be able to do that, but it was a thought I had trying to explain this delay.
I'm looking for ways to minimize GC so it does not impact the performance of the program (which is practically the only thing running on the computer). I've searched the web and the consensus seems to be that there is no way to either prevent GC, which is probably not desirable except for the most anal of developers, or even schedule it to only run at certain times. I'd try giving higher priority to the program and lower priority to GC, except they appear to run in the same thread which would seem to make that not possible. I suppose I could retain copies of all the forms in memory at all times, but would a lack of reference still invoke garbage collection?
Does anybody have information contrary to this? If not, is there anything you can suggest to improve performance at these times?