11-02-2015 01:56 PM
I need to create multiple clones of a couple VI's, and to have the VI's created to have a consistent numbering (1-8, for example), regardless of how many times I run the code (I call "Dispose Clones.vi" before I call "Create Multiple VIs.vi", both attached), and without having to close LabVIEW each time. And of course, I don't want the clones hanging around in memory, once I'm done with them.
One side questions is, what exactly is a clone's name? Does it include the string "(clone)" for example? As the attached screen shot illustrates, when I try to get a reference to a VI that is clearly in memory, I get error code 1004: "VI not in memory". I get the same results with all three strings I've tried (I temporarily modified the VI to try all three). This happens if the VI front panel is open or not. I'm including a shot of the code that creates the clones too, in case that is where the problem lies. My original idea was to keep the references as clones were created, but of course I can't do that using the strict VI Type.
But, getting back to the main question, how do I dispose of the clones so they are no longer in memory, and so the numbering restarts, without quiting LabVIEW?
If it matters, I'm currently running 2012 (for some reason, the shipment of my 2015 I ordered over a month ago is still not here).
Steve
11-02-2015 03:15 PM - edited 11-02-2015 03:15 PM
Your clone's name is "DAQ Engine.vi:21"; you're missing the ".vi".
In your creation VI you are creating a pool of clones (option 0x40), calling one, then dropping the reference to the pool without ever closing it or using oone of the other clones in the pool. If you call that creation VI in a loop you will build up a large number of unused clones which will never leave memory because you are never closing the reference.
11-02-2015 03:47 PM
Yes, thank you. At one time I did have the ".vi" in the name, but that didn't seem to work either. I see I left that version off in my post; sorry.
In any case, I realize I'm creating a large pool of clones, which I want to get rid of. That's my point. How do I do that? As I originally designed the code, I was storing the references to the VIs so I could dispose of them (See attached). But as I understand it, it's better to create them with strictly typed VI's (the x04 option), and that option does not leave me with a reference I can use to close it.
I'm game to use either method, if it will work, but prefere to use the strictly typed VI's (as in the first post), if I can. But, yes, I need to get rid of them, not only to save the memory, but to allow them to be numbered consistently every time I run the app.
Steve
11-02-2015 03:59 PM
Steve,
Can you attach a VI, or a Snippet, instead of a PNG? While we can look at a PNG, we can't "click" on it (to get Help for a function we don't recognize), and, more important, we cannot run it (with or without our modifications) to see what it is really doing.
Once I have a better idea what you are really trying to do (by looking at code), I'll go back and see how we managed 24 stations of cameras and VISA-reporting VIs (we had lots of clones running, and needed to shut down some if an error occurred).
Bob Schor
11-03-2015 12:59 AM
I think there's something you're missing about the 0x40 option - my understanding is that when using shared clones you're supposed to open a single reference and when you run the VI, LV decides on its own whether more copies need to be added to the pool, but you only ever manage one reference.
Personally, I never worked with this feature and always managed the multiple references on my own. In this case you can certainly have strict references and use the ACBR node to run the VI, but I don't remember the exact details, because there were some changes in how this works between versions. When it was first introduced it didn't actually match the documentation, but I believe in LV 2012 and later the 0x80 option should be enough (although you will need to check).
I don't understand the details of your system well enough to know whether shared clones will work for you, but if you need to maintain stays between runs of the application, you should save that state separately and then reload it when running again (either inside the clone or by passing the data in when running it).
11-03-2015 01:06 AM
@SteveVetter wrote:
In any case, I realize I'm creating a large pool of clones, which I want to get rid of. That's my point. How do I do that? As I originally designed the code, I was storing the references to the VIs so I could dispose of them (See attached). But as I understand it, it's better to create them with strictly typed VI's (the x04 option), and that option does not leave me with a reference I can use to close it.
I'm game to use either method, if it will work, but prefere to use the strictly typed VI's (as in the first post), if I can. But, yes, I need to get rid of them, not only to save the memory, but to allow them to be numbered consistently every time I run the app.
Steve
You're creating LOTS of pools of clones, one for each VI started, and LabVIEW can never get rid of them because YOU are never releasing them by destroying the references. When one works with the 0x40 pool option, one usually works with only one pool (one call to Open VI Ref, and keep reusing the ref).
There is no way to force clones to be destroyed (LabVIEW decides that) but if you don't force LabVIEW to create unused clones then it will use, and reuse, only the minimum number of clones needed.
There is also no way to enforce numbering, but why would you need that?
-- James