Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

While running a .net 3.5 application it always has a "System.OutOfMemoryException" error and it appears to be an ni488.2 problem. Any ideas?

Solved!
Go to solution

The NISPY report is as follows:

 

993.  ThreadIbcnt()
Process ID: 0x0000116C         Thread ID: 0x00001020
Start Time: 12:45:57.687       Call Duration 00:00:00.000
ibsta: 0x100       iberr: 0             ibcntl: 0(0x0)

994.  ibwrt(UD92, ":CHANNEL4:RAN...", 21 (0x15))
Process ID: 0x0000116C         Thread ID: 0x00001020
Start Time: 12:45:57.687       Call Duration 00:00:00.000
ibsta: 0x100       iberr: 0             ibcntl: 21(0x15)
Input Buffer
00000000:  3A 43 48 41 4E 4E 45 4C 34 3A 52 41 4E 47 45 20  :CHANNEL4:RANGE
00000010:  30 2E 32 34 38                                   0.248

995.  ThreadIbcnt()
Process ID: 0x0000116C         Thread ID: 0x00001020
Start Time: 12:45:57.687       Call Duration 00:00:00.016
ibsta: 0x100       iberr: 0             ibcntl: 21(0x15)

> 996.  ibdev(0, 7, 0 (0x0), T10s (13), 1, 0x0000)
> Process ID: 0x0000116C         Thread ID: 0x00001020
> Start Time: 12:45:57.703       Call Duration 00:00:00.000
> ibsta: 0x8000       iberr: 28             ibcntl: 0(0x0)

> 997.  ibask(UD93, IbaTMO (0x0003), INVALID)*********************************************ERROR IS HERE.
> Process ID: 0x0000116C         Thread ID: 0x00001020
> Start Time: 12:45:57.703       Call Duration 00:00:00.000
> ibsta: 0x8000       iberr: 28             ibcntl: 0(0x0)

> 998.  ThreadIbcnt()
> Process ID: 0x0000116C         Thread ID: 0x00001020
> Start Time: 12:45:57.703       Call Duration 00:00:00.000
> ibsta: 0x8000       iberr: 28             ibcntl: 0(0x0)

> 999.  ThreadIberr()
> Process ID: 0x0000116C         Thread ID: 0x00001020
> Start Time: 12:45:57.703       Call Duration 00:00:00.000
> ibsta: 0x8000       iberr: 28             ibcntl: 0(0x0)

> 1000.  ThreadIbcnt()
> Process ID: 0x0000116C         Thread ID: 0x00001020
> Start Time: 12:45:57.703       Call Duration 00:00:00.000
> ibsta: 0x8000       iberr: 28             ibcntl: 0(0x0)

0 Kudos
Message 1 of 20
(5,336 Views)

Hello,

 

We would need to know alot more information:

 

- What language is this app written in?

- what OS are you running on?

- When you look in Task manager or Process monitor do you see that you are running out of free memory?

- can you show the full error message?

- Has this application worked in the past?

- Does the error occur as the same point in the code every time?

- Does it occur on the first run or later on?

National Instruments
0 Kudos
Message 2 of 20
(5,308 Views)

Thanks for the help with this persistant error.

 

Answers to your questions:

What language is this app written in?  Visual Basic 2010

 

- what OS are you running on? XP Pro Version 2002 SP3

 

- When you look in Task manager or Process monitor do you see that you are running out of free memory?  PC memory consumption did not change during failure compared to runtime. Plenty of system resource available. See attached snapshots.

 

- can you show the full error message?

Visual Studios Error:

?ex.ToString
"System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.     at MasterESDTestProgram_08192010.ErrorHandling.ErrorHandler(Object ex)     at MasterESDTestProgram_08192010.K707Matrix.K707_dis(Object addrK707, Object addrK708)     at MasterESDTestProgram_08192010.MainForm.btnStartTest_Click(Object sender, EventArgs e)"

 

NISPY:

 

858.  ibwrt(UD32, "CG30X", 5 (0x5))
Process ID: 0x0000082C         Thread ID: 0x00000930
Start Time: 11:16:24.656       Call Duration 00:00:00.015
ibsta: 0x100       iberr: 0             ibcntl: 5(0x5)
Input Buffer
00000000:  43 47 33 30 58                                   CG30X

859.  ThreadIbcnt()
Process ID: 0x0000082C         Thread ID: 0x00000930
Start Time: 11:16:24.671       Call Duration 00:00:00.000
ibsta: 0x100       iberr: 0             ibcntl: 5(0x5)

> 860.  ibdev(0, 18, 0 (0x0), T10s (13), 1, 0x0000)
> Process ID: 0x0000082C         Thread ID: 0x00000930
> Start Time: 11:16:24.671       Call Duration 00:00:00.016
> ibsta: 0x8000       iberr: 28             ibcntl: 0(0x0)

> 861.  ibask(UD33, IbaTMO (0x0003), INVALID)
> Process ID: 0x0000082C         Thread ID: 0x00000930
> Start Time: 11:16:24.687       Call Duration 00:00:00.000
> ibsta: 0x8000       iberr: 28             ibcntl: 0(0x0)

> 862.  ThreadIbcnt()
> Process ID: 0x0000082C         Thread ID: 0x00000930
> Start Time: 11:16:24.687       Call Duration 00:00:00.000
> ibsta: 0x8000       iberr: 28             ibcntl: 0(0x0)

> 863.  ThreadIberr()
> Process ID: 0x0000082C         Thread ID: 0x00000930
> Start Time: 11:16:24.687       Call Duration 00:00:00.000
> ibsta: 0x8000       iberr: 28             ibcntl: 0(0x0)

> 864.  ThreadIbcnt()
> Process ID: 0x0000082C         Thread ID: 0x00000930
> Start Time: 11:16:24.687       Call Duration 00:00:00.000
> ibsta: 0x8000       iberr: 28             ibcntl: 0(0x0)

Why does ibsta go to 0x8000 at error?  And also iberr = 28? 

 

- Has this application worked in the past? No, this is a new application. The program always works for sometime and then this error occurs. It does happen approximately at the same point but not exactly.

 

- Does the error occur as the same point in the code every time? NO, but close.

 

- Does it occur on the first run or later on? This is test software, so I am able to perform many successful cycles of testing prior to failure.

 

I think that there may be a variable that is related to NI488.2 send/receive routines that is growing. Awhile ago I had to increase the value of the GpibDevice.DefaultBufferSize = 16384. It is this big now as a shotgun approach. Initially I increased it from 1024 to 2048. Is there documentation as to the proper sequency of events to perform a good send / receive and the variables to watch.  An object parameterlist may help?  Or maybe I'm on the wrong track?

 

Like I mentioned above the program does perform well for sometime, many cycles and then has this error, everytime about the same time but not exactly. I thought there was a buffer that may need to be increaased or reset within the ni488.2 parameters or something.

 

 

 

Here are my ni488.2 calls:


Private GpibDevice As Device
    Public ReadString As String

    Public Sub send(ByVal ud As Integer, ByVal GPIBAddress As Integer, ByVal Command As String, ByVal term As Integer)
        Try

            GpibDevice = New Device(CInt(0), CByte(GPIBAddress), CByte(0))
            'GpibDevice.DefaultBufferSize = 8388608


            ' errorStringSend = "send"
            'GpibDevice.BeginWrite(ReplaceCommonEscapeSequences(Command))

            GpibDevice.Write(ReplaceCommonEscapeSequences(Command))

        Catch ex As Exception
            'MessageBox.Show(ex.Message)
            ErrorHandler(ex)
        End Try
    End Sub

    Public Sub receive(ByVal ud As Integer, ByVal GPIBAddress As Integer, ByVal buffer As String, ByVal term As Integer)
        Try

            Windows.Forms.Cursor.Current = Cursors.WaitCursor
            GpibDevice.DefaultBufferSize = 16384 'sets the size of the return string. Default was 1024 and was too small.8/20/2010 CMS
            'ReadString = GpibDevice.ReadString()
            ReadString = InsertCommonEscapeSequences(GpibDevice.ReadString())

        Catch ex As Exception
            ErrorHandler(ex)
        Finally
            Windows.Forms.Cursor.Current = Cursors.Default
        End Try
    End Sub
    Private Function ReplaceCommonEscapeSequences(ByVal s As String) As String
        Try
            Return s.Replace("\n", ControlChars.Lf).Replace("\r", ControlChars.Cr)
        Catch ex As Exception
            ErrorHandler(ex)
        End Try
    End Function 'ReplaceCommonEscapeSequences

    Private Function InsertCommonEscapeSequences(ByVal s As String) As String
        Try
            Return s.Replace(ControlChars.Lf, "\n").Replace(ControlChars.Cr, "\r")
        Catch ex As Exception
            ErrorHandler(ex)
        End Try
    End Function 'InsertCommonEscapeSequences

End Module

0 Kudos
Message 3 of 20
(5,290 Views)

Hello,

 

The Error you are getting is explained in 488.2 manual:

 

EPWR (28)

Error Condition:
The Interface lost power.
Possible Cause:
EPWR results when an interface loses power. This often results when the system goes to and returns from a standby state.
Solutions:

  • Take all handles offline and reinitialize the application
  • Quit the application and restart the system
  • Disable standby and hibernate modes on the PC

 

National Instruments
0 Kudos
Message 6 of 20
(5,246 Views)

If this is a PCI GPIB card, try the above, turning off hibernate and sleep modes. If this is a laptop and you are connected to a USB GPIB interface, you may need to look deeper into the power settings to turn off and USB port power saving features which may cut power to those ports and is common on laptops.

National Instruments
0 Kudos
Message 7 of 20
(5,245 Views)

Hello again, for posting SPY captures, just attach the SPY file so that it can be opened in NI SPY as the txt version does not display nicely.

National Instruments
0 Kudos
Message 8 of 20
(5,240 Views)

I don't believe there is a problem with the GPIB card. Why: We run a VB6 application for days without any issues. My VB2010 application, which is a rebuild of the VB6 application, always fails with the discussed error. So with this, I believe the hardware is good but maybe the configuration of the .net 3.5  ni488.2 code may need tweeking, maybe a parameter is too tight?

0 Kudos
Message 9 of 20
(5,150 Views)

This is a PCI-GPIB card installed in a PC. As I said prior, the hardware works with my VB6 application for days, so I don't believe this is an issue.

0 Kudos
Message 10 of 20
(5,148 Views)