LabVIEW VI Caching on Network Drives with Unchanging Timestamps
0 reputation · 28 Dec 2023, 14:00 UTC
0 reputation · 28 Dec 2023, 14:00 UTC
When developing LabVIEW applications on network drives where file‑system timestamp updates are unreliable, the VI caching mechanism may retain stale compiled code after source modifications.
The goal is to guarantee that any edit to a VI is reflected in its next execution without resorting to a global cache disable that could degrade performance.
Uncertainty remains about which configuration or permission settings can trigger a selective cache refresh or enforce recompilation for specific VIs while preserving the performance benefits of caching for unchanged code.
What configuration options exist to force VI recompilation without disabling caching globally?
Can LabVIEW be configured to use a checksum‑based invalidation instead of timestamps?
Is there a way to programmatically clear the VI cache for individual VIs after a source update on a network drive?
LabVIEW’s cache is timestamp‑based. On a network drive that does not update timestamps reliably, a VI can appear stale. The following options let you force a recompilation for a single VI while leaving the global cache enabled.
No built‑in checksum‑based invalidation exists; the mechanism always relies on file timestamps. The only alternative is to manually clear the cache for the affected VI after editing.
SMB and other network file systems often delay or suppress last‑modified updates, especially when opportunistic locking is enabled. This leads LabVIEW to think the VI hasn’t changed.
Open the VI in question. Go to File → VI Properties → Execution and check Disable caching. This setting is stored in the VI’s metadata and is respected only for this VI.
Save and close the VI. Re‑open it; the next run will load the source from disk and recompile, regardless of the timestamp.
Programmatic alternative:
viRef = VI.Server.Application.Reference.GetVIReference("\\network\path\my.vi");
viRef.CacheEnabled = false; // disables caching for this reference only
viRef.FlushCache(); // removes any existing compiled code
After the FlushCache call, the next execution will recompile the VI.
Verify the change. Add a visible indicator or use Probe to confirm that the updated block diagram is executed.
LabVIEW does not expose a setting to switch from timestamp checks to checksum or hash comparisons. The caching algorithm is hard‑coded to use the file’s last‑modified time.
Disabling caching for a VI increases execution time, especially for large block diagrams or tight loops. Use the property only for VIs that are edited often. After the VI is stable, re‑enable caching to regain performance.
Because the cache is per‑application, any changes to the VI file on disk while the VI is running will not be seen until the VI is closed or the cache is flushed.
If you notice that the VI still runs old code after clearing the cache, check whether File → VI Properties → Execution → Disable caching is still unchecked and whether the VI is currently open in another LabVIEW instance. Resolving that will typically restore the expected behavior.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.