From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Re-obtaining Notifiers to Send Notification (rather than wiring them)

 I have a program that has a dozen or so different notifiers, and the thick wires going off to the Send Notifications were getting messy. So, rather then using the wire, I just use another Obtain Notifier (named) and thus have a virtual wire. I only do this for the Send Notification function. The Wait on Notification typically occurs in only one place (consumer loop), so it is wired.

 

Some of these re-obtains occur in loops which may run hundreds of times, and the notifiers are not released until the program, ends.

 

I'm wondering what type of performance hit I'm taking with this approach? Memory? Speed?

 

Thanks. 

 

Richard






0 Kudos
Message 1 of 6
(2,793 Views)

Why are you obtaining the reference for each notifier more than once? This is the same approach as file-streaming vs. high level "Write to Spreadsheet".

It definetly has a negative impact on performance, so i suggest you to check out more "streaming like solutions" for the notifiers...

 

hope this helps,

Norbert 

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 2 of 6
(2,791 Views)

Each time you do an Obtain Notifier by name, you will be creating a new reference to the desired notifier (ie causing a lookup to find the object, then creating a small amount of memory to act as a pointer refnum, etc). When looping and not disposing of the notifier, this will cause a small memory build up (not a "memory leak" per say, but additional memory that you dont need).

 

Therefore, especially in the case of loops, it is more efficient in terms of speed and memory allocations, to do an Obtain Notifier once and then reuse the same reference. If you really dont want to pass the notifier wire to your looping VIs, at least put an Obtain Notifier outside of the loop and pass the reference in along a shift register or tunnel.

 

This is similar to the whole "avoid creating arrays inside loops" philosophy in that even though it is possible and sometimes easier to use the build array inside a loop, if performance is an issue, it is generally best avoided if possible.

 

Shaun 

Message 3 of 6
(2,783 Views)

shew82 wrote:

When looping and not disposing of the notifier, this will cause a small memory build up....

 

 

Shaun 


That's what I thought, but memory manager software is showing that memory is not building, hence my post on here. However, I haven't left it on for several hours. I think I may stick with this configuration for the Send Notifications that only happen a few times.

 Thanks for the reply. Smiley Happy

Richard






0 Kudos
Message 4 of 6
(2,776 Views)

Hi Broken Arrow,

 

You will see a performance hit due to the overhead necessary to run the extra Obtain Notifier Functions to create the notifier refnum as well as the auto-cleanup of the refnum when the loop iterates. Because of this auto-cleanup, you won't see too much of a memory build-up, but simply having the extra Functions will add to memory consumption.

 

Also, to reiterate what shew82 posted, it is more efficient to obtain the notifier once outside the loop and then wire the refnum to each loop thru a tunnel.

 

As far as releasing the notifier, you only need to call the Release Notifier Function once as long as you have the "force destroy?" input set to TRUE.

 

Thank you for choosing National Instruments.

 

Aaron Pena

National Instruments

Applications Engineer

http://www.ni.com/support  

Message 5 of 6
(2,748 Views)

Aaron P wrote:

... it is more efficient to obtain the notifier once outside the loop and then wire the refnum to each loop thru a tunnel....

 


Absolutely, and that's what I've been doing for years, until one week ago, when I did the re-obtain trick in about 20 places and expected a performance hit, and didn't see it. However, i have changed the code back to what is "right" rather than what is "handy". My thought was that maybe the re-obtain just looks up the existing reference rather than actually getting another copy.

 

Thanks for the reply.

 


Aaron P wrote:

Thank you for choosing National Instruments.

 


It chose me.

 

Richard






0 Kudos
Message 6 of 6
(2,742 Views)