Creating a menu in IntraWeb applications is pretty easy: Just drop a TIWMenu and a TMainMenu component on your form and conect both. But unfortunately there is a serious catch.
Using the standard VCL TMainMenu component makes it really a
snap to add a nice menu to your IntraWeb application:
Resource issues
We recently got a support inquiry, which said that an IW application starts
throwing errors, when there were more than about 50 simultaneous sessions. As we
have applications, that easily handle hundreds of sessions, it was clear that
these error must have had its source in the customer’s code. We looked at it,
and searched for obvious “candiates” like global variables etc. but there
was nothing. After some more investigation it turned out that the errors
were somehow related to TIWMenu.
This erroneous application had a TMainMenu component with about 220
TMenuItems. Ok, so we started digging into the source of IWMenu, to see if
there were improperly freed resources – but we found nothing.
TMainMenu is limited
As even the Delphi Debugger crashed when we hammered on the test application,
this started to be one of those issues, which are really no fun to debug.
After a while we came to the idea “What, if TIMainMenu (i.e. the VCL
component) has an resource issue itself?”. So we created a trivial VCL
forms application that just created lots of form instances with a TMainMenu
component on it (we used this big one, with 220 MenuItems).
Bingo! After 20-30 instances the application just blows up, if you run it
through Delphi’s debugger, then the debugger blows up. In other words:
TMainMenu is not designed to be created a lot of times. Its designed to work
for a Desktop application, which usually has just a handful open forms at a
time.
Solution
If you want to have a menu in your IntraWeb applications, then be careful,
that you don’t add too many MenuItems. Also if you expect to have
many simultaneous sessions, then you better keep off TIWMenu/TMainMenu
at all. For the VisualStudio incarnation of IntraWeb we have our own “TMainMenu”
implementation – maybe we are going to back port that to Delphi …
I can not really tell how much “many” is in this context – I
only can recommend to be carefully. Again, this is not an IntraWeb issue, but a
VCL/TMainMenu one. I don’t believe that Borland is going to look into that,
because it’s just not designed to be used that
way.





Entries (RSS)