I know that you can call viClose after viOpenDefaultRM, but I'm wondering what happens if viClose is never called with the handle from viOpenDefaultRM. Will there be resources leftover? Also, does multiple calls to viOpenDefaultRM simply return the same handle, generate a new handle, or does it allocate and initialize the VISA library every time? If it allocates and initializes the VISA library every time, then viClose should probably be called. If it returns the same handle, there may be an issue when closing. For example:
- funcA calls viOpenDefaultRM and opens an instrument
- funcB calls viOpenDefaultRM and opens another instrument
- you call funcA, then funcB, then viClose on the the handle from funcA
According to the documentation, it seems as if both instruments will be closed since they were opened with the same RM handle. If this is the case, it may be better not to call viClose on the default RM. So should viClose be called with viOpenDefaultRM?