PropertyObjects Were Not Released Warning When Using LabVIEWPrimary Software: TestStandPrimary Software Version: 3.1 Primary Software Fixed Version: N/A Secondary Software: LabVIEW Development Systems>>LabVIEW Base Package
Problem: I am using a LabVIEW User Interface (UI) or code module that converts an ActiveX variant wire to a property object. When I shut down my UI, I receive a warning that PropertyObjects were not released: How can I prevent PropertyObject leaks? Solution: This warning is happening because the TestStand engine is shutting down before LabVIEW has released all property object references. It is good LabVIEW practice to close all references by using the Close Reference VI. The most common cause of PropertyObject leaks is an unclosed reference. If you are sure that you have closed all of your references, there is another possible cause of this leak. Variant wires can hold references to PropertyObjects. However, variants cannot be closed explicitly, and will not be freed until the VI leaves memory. If you have a variant wire in your VI that holds a reference to a PropertyObject, to prevent this warning from happening you will need to move the conversion between a variant and an ActiveX reference to inside of a dynamically called VI. A dynamically called VI will be removed from memory upon completion of execution. When the VI is removed from memory, the variant data will be freed. Attached to this KnowledgeBase you will find two zip files containing VIs you can use for this purpose. If you are using LabVIEW 7.1.1, please download Dynamic Variant to Data 7.1.1.zip. If you are using LabVIEW 8.0 or later, please download Dynamic Variant to Data 8.0.zip. Each zip file includes the necessary VIs, an example sequence, and an example VI that shows how to use the dynamic VIs. When you use the attached SubVI, you will need to use it in addition to the Variant to Data VI that is already converting the variant. Also, be sure to close the reference that it creates as shown below in Figure 1.
ActiveX references work by keeping a 'reference count' of the number of users of the reference. This reference count is initialized to one when the reference is created. Every copy of this reference increments the reference count. To properly free the reference, programs must decrement the reference count. When the reference count reaches zero, the system automatically frees the reference. In LabVIEW, the reference count is incremented whenever a new wire is created, and calling the Close Reference VI decrements the reference count. However, if the new wire is a Variant wire, we cannot close the reference explicitly. In this case, the only way to free the memory and decrement the reference count is to have the VI containing the variant leave memory. Especially when using UIMessages which are handled by reentrant callback VIs, the best way to ensure that the VI is unloaded from memory is to use a dynamically called VI. The VIs and examples attached show proper useage to prevent PropertyObject leaks. Related Links: LabVIEW 2009 Help: Open VI Reference Function LabVIEW 2009 Help: Close Reference Function Attachments:
Report Date: 01/07/2008 Last Updated: 01/07/2010 Document ID: 4H6DULT3 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
