Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

VISACOM - Alloc Error using 488.2 USB-B Interface - too many open sessions

I have been having the following issue in my VB .NET RF-ATE application.... It usually happens when my program enters a measurement loop (I.E. searching for P1dB). It begins to solve for P1dB and performs about 15 cycles (sets power level on SigGen and takes SpecAn meas) and then crashes due to the following error :

As Logged in the Event Viewer :
VISA: May 13 09:45:22: Error=bfff003c,"VI_ERROR_ALLOC: Insufficient system resources/memory": ViTable::add - too many open sessions

As Logged in VB .NET :
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in RFATE.exe
Additional information: HRESULT = 8004003c

VI_ERROR_ALLOC

Not sure why its happening my code is pretty solid (or so I thought) and I believe it closes the VISA session properly after each R/W operation? (See attached). I call the same procedure to talk to the GPIB instruments over and over.

Is it possible that I am not freeing and disposing of resources properly? I have read a little about destructors in .NET etc. but I was under the impression that as soon as "Sub End" is executed that the resources were free'd up? But that doesn't explain why I would get a "too many open sessions" error occour if I am closing the session after I am finished?

Another odd thing to note is that I have created testplan scripts and loaded them into my application with literally hundreds of measurement commands and my program didn't crash then???

I am very new to VB and .NET (3 months) so I have a lot to learn but I can't understand why this is occouring. Any help is appreciated.
0 Kudos
Message 1 of 2
(6,883 Views)
Just posting a followup... Turns out I found a way to make it work! (I have been fighting this for almost 3 days!).

If you look at the variable declarations of my procedure.....

Sub GPIB(ByVal Addr As Object, ByRef Data As Object, ByVal IO As String)
Dim ioMgr As Ivi.Visa.Interop.ResourceManager
Dim instrument As Ivi.Visa.Interop.FormattedIO488
Dim session As Ivi.Visa.Interop.IMessage

I use the "IMessage" interface for the variable session.

Just before the "Sub End" is executed I use the following line to close the session :
session.Close

Which it would appear doesn't close the session properly when you use the "IMessage" interface.

So I changed the line to use the "IVisaSession" interface instead :
Dim session As Ivi.Visa.Interop.IVisaSession

Now when the Close method is executed aparently it closes the session properly because my program isn't crashing at all!

I was using VISA COM 3.0 Reference object (GlobMgr.dll).

If anyone has any insight on this please do share.
Message 2 of 2
(6,876 Views)