LabVIEW Call Library Function Node Not Unloading a DLL After VI Execution

Updated Jan 4, 2024

Reported In


  • LabVIEW

Issue Details

  • After I run a VI containing a Call Library Function Node in LabVIEW, the DLL it calls gets locked as if LabVIEW is still using it, even after the VI stops running.
  • I would like to only load my DLL in memory when it is called in my LabVIEW program and then unload it at the end of the program.


When LabVIEW uses the Call Library Function Node to call a DLL it will create a reference to the DLL and that will be kept in memory until the VI that called the DLL is closed. You can workaround this by dynamically unloading the DLL or have the VI calling the DLL being dynamically called by a different VI.

Dynamically Unloading a DLL

After LabVIEW 8.2, Dynamic Link Librarys (refered to DLLs from now on) can be dynamically loaded and unloaded. The Call Library Function Dialog Box help mentions the process needed to load and unload the DLL. In summary:

1. The Specify path on diagram option needs to be checked in the Call Library Function Dialog Box. The dialog box can be opened by double clicking on the Call Library Function node, as shown in the figure below. 

2. After the Specify path on diagram parameter is checked, a terminal named path in appears on the Call Library Function. This terminal accepts the path to the DLL that you want to call.  When that Call Library Function is executed, the DLL specified in the reference is loaded into memory.

3. The path in input can be used to unload a previously referenced library from memory. You must wire an empty path constant or null path constant to the path in input of the same Call Library Function node that initially called your DLL. The picture below shows an example. The first call loads the DLL and the boolean unloads the DLL as well as stops this code. The false case, not shown, has timing but no code.

This image is a LabVIEW snippet, which includes LabVIEW code that you can reuse in your project. To use a snippet, right-click the image, save it to your computer, and drag the file onto your LabVIEW diagram.

Using Dynamically called VIs


If the VI that uses the Call Library Function Node is closed, the reference to the DLL will be released. Therefore, if you have a VI dynamically calling a secondary VI with the DLL reference you can close the secondary VI, releasing the memory of the DLL's handle, without a need to close the primary VI. For more information on how to achieve this using the Open VI Reference you can refer to Dynamically Calling a VI in the LabVIEW product documentation.

Additional Information

If an empty or invalid path is wired to a different Call Library Function node than the one that initially called your DLL it will not unload the DLL from memory. This can cause a LabVIEW Access Violation crash, due to the unloaded DLL. The picture below shows an example of what not to do: