Very nice problem was encountered yesterday. I have a control (doesn't matter which one - Vision/Picture or Boolean), where I needed dynamically created Run-Time menu, which is called on Right Mouse Click. The problem is that this menu can be shown only limited number of times, and this depends from amount of the items in the menu. For example, menu with 10 items can be shown roughly 3300 times only. Then exception is coming. Menu with 4 items will cause crash after 8K clicks and so on. If we put 8000 items into menu, then 4 clicks is enough, 5th will cause exception. Memory leak is also observed. Exception happened in Insert Menu Items primitive.
Was checked in LabVIEW 2010 and 2014. Both are affected (Dev environment and Run-Time).
Here is short video with explanation:
The test project in attachment.
The question is - do you have any idea about "low cost" workaround (except using WinAPI or self-made menus)? The requirement is - this menu should be generated at run-time, because could be different from run to run.
Wow looks like a bug. Just curious, how did you find this? It seems that even with a UI that is heavy on the right clicking, getting that many right clicking menu items would take a very long time to see. And then to take the time to troubleshoot and figure out what was causing a massive crash like that. I'm guessing it was a program that ran for a very long time without any problems.
Uff. 8kx4 is a very suspicious number. It would lead to believe that somewhere in the background an I16 value is wrapping, causing an exception.
I would guess that you can open a maximum number of 32768 items int he menu before it crashes.......
Yes, Intaris, its true. Definitively looks like I16 or may be U16 counter (I have "two-levels" menu).
In additional, every time when huge menu is appeared, then memory allocated, but not released:
with small menu memory leakage is moderate, but when numer of items is huge, then can be clearly observed.
My first idea was to use Close Reference, but unfortunately Close Reference cannot be directly used for Menu Reference (even if can - not sure if this help).