LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

DataSocket memory leak problem (2VO0SF00) -- more info?

I ran a VI using DataSocket which passed the reference wire out of the DataSocket Write, and into an indicator, very similar to example 9.  The VI ran over the weekend and did not crash our test computer or show any unusual behavior.  This leads me to believe that you would be safe using this setup, as far as avoiding memory leaks.   
0 Kudos
Message 11 of 20
(1,793 Views)

Aha, that's great news! I'll start converting my VI's over to this solution.

Thanks for your all your help,

Patrick

0 Kudos
Message 12 of 20
(1,786 Views)

Hi guys,

I am with a question in the same lines as this discussion, but a bit further so thought to put my query in this discussion.

 

Actually, I have already implemented Datasocket with connection id references (indicators from datasocket open, and then local variables), because I need to operate on multiple datasocket connections and need to read them at multiple locations. So after a discussion in another thread, I have implemented this method.

 

But now, my question is where to close those connections? Should I close them at each place where the local variables are used (each copy of the local variable to be closed separately?) or should I close at just one point (but then I am not sure which will be the last point to read those DS connections)?

 

I used the example9.jpg made by Patrick :P, and modified it a little bit to explain my case(s). If not clear, I can post my code also.

 

Thanks ahead!

Vaibhav
0 Kudos
Message 13 of 20
(1,642 Views)
Hi, can you explain to me why you are using shift registers at all.  The references are constant, are they not?  If they are constant then you only need to close them on the outside of the loop, and you can change the shift register to a normal tunnel.
Chris Bakker
SET Americas
CEO

0 Kudos
Message 14 of 20
(1,620 Views)

I must say that none of this makes a lot of sense?


Vaibhav wrote:

...each copy of the local variable to be closed separately?


 

I don't think you understand the concept of a local variable. A local variable just points to a control or indcator, it does not have it's own life that needs to be closed seperately. Do both of your local variables point to the same indicator (after all, they all have the same name)? You just have one big race condition, because the final value of the indicator depends only or the arbitrary order things are written.

 

The closing on the left can be done in a simple FOR loop, with 20% of the code. Same with the open on the left.

 

If you need to wait until both loops have finished before closing the ds connections, place a sequence that has a data dependecy for on both loops. This way it can only execute once both loops have finished. 


Vaibhav wrote:

 because I need to operate on multiple datasocket connections and need to read them at multiple locations.


 

Can you attach some actual code that shows your "multiple locations" so we get a better idea what you are doing.

 

Message 15 of 20
(1,607 Views)

Hi there,

 

@ Chris

yes, you're quite right. the datasocket connections could be used as tunnels (as they were previously), but I recently changed them to shift registers as suggested for a better practice, because it maintains the connection id, and also, I don't need to select "use Default if unwired" option in case I use multiple cases.

But yes, I agree, they could be just tunnels.

 

@ Altenbach

well, you're right. I agree. The local variables need not be closed individually. I was stupid to think like that. 😛

And yes, I liked the idea of putting a sequence that executes only after all the loops finish execution. Just one more question. How do I create a data dependency? Is it possible that I just extend a wire from all the three loops which take out the status of execution (stopped, hence "true") to the sequence structure and check if "all true" then close DS?

 

I have attached the code herewith. Inside the case structure on the right, there are 3 timed loops, namely "Timed Loop Resources," "Timed Loop Clients" and "Timed Loop Brokers" and they have their corresponding datasocket connections to "read from" and these are with "shift registers" and are closed after the loop, on the extreme right top, of each loop. But there are three more connections (with write mode) which are referred in all the 3 timed loops, to write messages to. And my question was about this. I have closed them in the event structure below the 3 loops, but also created a sequence structure on the right, as suggested by Altenbach.

 

Thanks ahead.

Vaibhav
0 Kudos
Message 16 of 20
(1,579 Views)
Hi,  I am still a bit confused about exactly what you are asking about the code you posted.  There is nothing logically wrong about what you are saying about closing the DS when the status shows done for all three loops.
Chris Bakker
SET Americas
CEO

0 Kudos
Message 17 of 20
(1,566 Views)

Hi Chris,

yes, now it's changed, and I have added that sequence structure at the right side, after Altenbach suggested. But earlier it was in that while loop with case structure, at the bottom of those three timed loops. And that was not a good place to close the DS connections, because we don't know still if any of those three timed loops is running or not. So I changed and posted to show both old and new ways.

 

And regarding your previous comment, about shift registers and tunnels, could you see them?

 

Any comments are welcome.

Message Edited by Vaibhav on 08-15-2009 10:24 AM
Vaibhav
0 Kudos
Message 18 of 20
(1,534 Views)

Hi,  You still dont need any sift registers to makesure the same reference is seen by every iteration of the while loops.  Also if you just connect any wire from the output of the while loop to a sequence structure with the close DS connection VI in it, the data flow model of LabVIEW will ensure that all three while loops complete before the sequence structure is executed.

Chris Bakker
SET Americas
CEO

0 Kudos
Message 19 of 20
(1,500 Views)

Hi,

Do you mean the output of the "End" variable from any of the while loop, connected to the sequence (like right now all the 3 "End" variable are connected) will make sure the sequence structure executes only after the 3 loops are finished?

How/why?

 

The value of this "End" variable is set in a different loop (other than the 3 loops) and although it will be the same for the 3 loops, I think one loop could take more time to finish its last cycle than the others, and in that case if by chance we have connected the output from the loop that finishes its cycle before the others, it will pass the value to the sequence structure, no? Perhaps I don't understand the data flow well, then.

 

Can you please clear this doubt?

 

Vaibhav
0 Kudos
Message 20 of 20
(1,489 Views)