Greetings
While checking and optimizing one of my projects, I have stumbled on one weird behavior creating new forms at runtime. After creating each new form, forms initialization-creation time increases from 20 ms to even several hundred millisecond, couple people are reporting that form creation takes some several seconds, cant check those cases because I don't have access to those PC's.
And it all comes down to NextGrid. If form has one or two grids, creation time increase is negligible from none to few ms after 10 forms created. But, we have a form witch contains a tabcontrol with 14 tabsheets, each of those contain 1-4 NextGrids, in total around 22 mostly small and a few larger grids. smaller ones do contain atmost 10 columns, largest 2 grids contain no more than 20 columns.
There where no issues with filling all those grids with data as I initially did suspect, there is single SQL call returning an XML from which all grids are then filled, request and filling takes constant 200-400 ms on create event.
I did create a test project with two forms , copied all components from project's troubled form without any logic functions and database components and tested creation times.
Initially first form creates and shows in 550 ms, from which form show takes 40 ms, initialization time is around 510 ms, after each consecutive form is created and not freed, initialization time increases by around 100 ms and more, for example:
-512 ms first form
-622 ms second form
-778 ms ...
-903 ms ...
-1093 ms ...
if all 5 forms have been closed and freed, new forms creation time drops back to 530 ms.
After deleting all grids and doing same test, with little bit more than 300 other visual components left on the form (like labels,buttons, editboxes, comboboxes, timages and several other standard and Next components)
form initialization times are around 180-200 ms and shows at 220-300 ms and those times are constant even if there are created and left open more than 30 same forms.
I only observed this problem using nextgrid and nextdbgrid components.
On all windows versions ranged from XP to windows 10 programs behavior is about the same, only for some initialization takes longer for some shorter time spans.
Program originally is written using Delphi XE2 and nextgrid verion 5.9.50 , did run test app using Delphi Berlin 10.1 update 2 too, With Berlin, creation times where slightly faster but not by much, few milliseconds.
Is this normal or is there a reason why after creating each form it takes longer to create the form with nextgrid components?
Another note, those users who reported really long times (even up to 20 seconds) did say that problem persists even after closing application, until you rebooting system, then it returns to normal behavior for 1-2 days described above and after that (if pc is left running without shutdown) forms create slower and slower and pc needs to be rebooted. There are no memory problems or memory leaks which i know and fastmm4 didn't report any, no viruses or other causes, other applications like excel or browsers work fine without noticeable changes. But I doubt that those cases are linked to this problem and cause might be somewhere else, but who knows.