Just a general question: are unhandled events bad? Do they introduce a memory leak? Being lazy, I just bundled my 4 User Events into a typdef cluster, and I used it through my whole project, like in dynamically called VIs, and some subVIs too. So I just registered for all of these 4 Events in every Event Structure.
There is not a single VI in my project where I need all of the 4 User Events to be used in the actual Event Structure of the VI, so of course this approach caused lots of unhandled events (visible using the Event Inspector Window). I am not sure if unhandled events can cause problems after longer runtime? I guess memory leaks?
Anyway, I cleaned up my project, and now I only register EVERY Event Structure for those User Events which are actually handled in their cases. So I do not see "unhandled events" any more in this Event Inspector Window.
So practically my question is that, how bad are these unhandled events? One of the User Event was generated at every sec (data broadcast to some modules from a DAQ loop).
Solved! Go to Solution.
Personally, I do not think they are a problem. I use a similar architecture to the one here https://decibel.ni.com/content/docs/DOC-12159
I send my events everywhere and then a helper loop sends them to a local loop. I believe there are no memory leaks, but, if you have a tight loop, you will be receiving a bunch a messages that you end up ignoring, which will slow down the loop slightly. That is why I use the helper loop.
FYI If you have not seen this https://github.com/JackDunaway/LabVIEW-User-Events-Tips-Tricks-and-Sundry
I highly suggest it, extremely useful information. I believe it shows no memory leaks also.
At one point I incorrectly posted that unhandled events caused problems but was corrected.
Hmmm, I'm not sure the stated information from Craig S. is correct about event structures automatically discarding events they have not been registered for. I would actually view this as a bug.
It doesn't match my testing history at all. Mind you, I utilise almost exclusively UserEvents, and maybe it's a difference if we're talking about Control Events or UserEvents......
If you have a VI that shows that they are not discarded I would be interested in seeing it. You are correct that the above statement is for dynamically registered user events and not those of front panel controls although I would not expect them to be different.
I have just tested it and it is indeed exactly as mentioned, an Event structure deletes all registered events which it is not told to handle.
But I'm not sure I'd put this in the "feature" box, for me it's a bug. It's actually a bug I've spent time working around (i.e. making sure all UserEvents ARE being handled in order to prevent memory leaks) only to find out now that this can never actually lead to memory leaks......
So if I have code where two event structures are wired up in series with the same Registration Refnum but handle only some in the first structure and the "rest" (which by this time no longer exists) in the second then the second event structure never actually sees anything because the first has decided to discard all of the otherwise perfectly valid events.
So I learned something valuable today.
I remember Jack Dunaway giving a presentation at NI Week 2013 that had lots of goodies on Events. One of the things I remember him touching on is there were a few cases where memory leaks could occur in 2012 that were then fixed in later versions. One was generating events that no one was registered for. I know this doesn't directly answer the question (that's already been answered) but Jack had a lot of good info and it is worth a watch since it was recorded.
Video (FTP and under NIWeek 2013)
I remember the presentation and I remember my mind being blown.
The fix for memory leaks is not something which stuck with me unfortunately. Still, a day where I learn something (even if it's for the second time) is not a wasted day.