06-07-2018 10:38 AM
OK, it took some time, but now I removed all Stream Channels from all of the 8 modules called from the top level VI, I only left Channels maybe at a couple of places where they do not play major role.
So inside each module, a single Stream Channel connected the Event Loop with the State Machine loop. I replaced each of these with a Queue, since it gives me the same functionality I need (Enqueue, Dequeue, "Timeout (msec)" input, "Timeout?" bool output).
Voila! Memory leak is GONE! The memory consumption stays "beton solid" around 300MB!
06-07-2018 10:42 AM
Nice!
Maybe you or Bob Schor can explain the advantages of Channels over other methods. I have not tried them yet, and so far, have only seen some bugs in the implementation in these forums along with the problem of sharing projects, ie, rebuilding the channel vis etc. So far, I have not seen a compelling reason to use Channels, why did you pick them for this project over a queue, user event, etc?
Cheers,
mcduff
06-07-2018 10:52 AM
@mcduff wrote:
Nice!
Maybe you or Bob Schor can explain the advantages of Channels over other methods. I have not tried them yet, and so far, have only seen some bugs in the implementation in these forums along with the problem of sharing projects, ie, rebuilding the channel vis etc. So far, I have not seen a compelling reason to use Channels, why did you pick them for this project over a queue, user event, etc?
Cheers,
mcduff
First of all, I massively use User Events in this very project!!! All the "inter-module" communication is done via Dynamic User Events. You just cannot live without this, so powerful.
However, I wanted to use Channels for "intra-module" communication, so to transmit data inside a Module, between two loops (or sometimes 3). If you use Channels, you need less wire, this is the very first advantage. Of course, you can dig deeper into more complex Channel types, and find even more useful things. Well, lets hope these teenager issues will be solved soon regarding to Channels, and they will be safe to use. I cannot recommend it now. I just got burned too much yesterday 😉
Ah, here is a visual explanation (non functional) why it is more "tidy" to use a Channel over a Queue:
06-07-2018 11:01 AM
Got it. Thanks.
I use User Events for intra and inter communications between modules, one User Event is Local the other can communicate with any other module. Similar to
Each module is basically a JKI State machine so events are built in.
mcduff
06-07-2018 01:57 PM
As the Champion of Channels (and working furiously behind the scenes to better document the current set of recently-introduced problems), I want to extend Blokk's Example of Streaming with Queues vs Streaming with Channels. You usually stream between While Loops, and there's always the issue of (a) stopping both loops and (b) making sure the "communication path" is preserved until the need for it has finished. With Queues, this can be accomplished by having the Producer send an "All Done" signal (here the "illegal" Dbl value NaN) after the Producer loop has been told to stop and the Consumer recognizing this signal, stopping itself, and then (safely) Releasing the Queue. Here is the example:
Not too bad, but it would be "interesting" to explain this to someone new to LabVIEW. Here is the Channel version of the same code:
So much simpler -- the Stream Channel includes a "Last Element" input that the Producer sets and the Consumer Reads. The only weird thing in this example is the path of the Channel Wire, but that's an aesthetic choice -- the following is even simpler:
Bob "Channel" Schor
06-08-2018 09:02 AM
Hmm, today I got another crash, and started to probe more the things! So far I only looked at some time stamp indicators, and it appears it fooled me! 😄
So good news for the Channels and bad news regarding to my troubleshooting skills: i found a code part in the Analysis module, where by mistake I set a timeout value for zero instead of "-1"!
(Bob, in the project I sent you, the "module_Analysis.vi" has a Case in the state machine loop, called "step1". Here the "timeout" wire through is wrong, it should be replaced by a constant "-1"!)
So this module in certain conditions started to send data as fast as possible to the other module! Thus flooding the memory like hell.
Pfff.... From this I really have to learn: instead of making up theories and producing youtube videos, I should have put more effort into proper debugging!!! 😄
So, at least in this very case, looks like Channels are INNOCENT! 😉
Apologies for my really amateur mistake!!!
06-08-2018 04:05 PM
Yay! Not that I haven't done equally silly things (but so far, only twice today ...). Channels, bugs and all, Rock!
Bob Schor