07-14-2017 10:47 AM
Hello,
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.
07-14-2017 11:22 AM
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.
cheers,
mcduff
07-14-2017 11:56 AM
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.
mcduff
07-14-2017 12:11 PM
At one point I incorrectly posted that unhandled events caused problems but was corrected.
07-14-2017 12:36 PM
Thanks to both of you for the useful info! 🙂
07-17-2017 08:28 AM
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......
07-17-2017 08:38 AM
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.
07-17-2017 09:47 AM - edited 07-17-2017 09:57 AM
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.
07-17-2017 02:17 PM
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.
Content:
https://github.com/JackDunaway/LabVIEW-User-Events-Tips-Tricks-and-Sundry
Video (FTP and under NIWeek 2013)
https://lavag.org/topic/16091-ni-week-2012-videos/
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
07-18-2017 02:38 AM
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.