Memory Leak

I have a memory leak with jsut a simple quering of the clips on the centera.  We are trying to get to the attribute information.  We see that if you go after 10,000 clips the program memory usage increases from 6mb to over 203mb then crashes.  We see the memory climb on every clipopen call and fetchresult.  I have to be missing something - pls tell me what I am missing.

Dim queryResult As New FPQueryResult

Dim queryStatus As Integer = myQuery.FetchResult(queryResult, -1)

While queryStatus <> FPMisc.QUERY_RESULT_CODE_END And queryStatus <> FPMisc.QUERY_RESULT_CODE_ABORT And count < uCount
                    If queryStatus = FPMisc.QUERY_RESULT_CODE_OK Then
                        tempname = queryResult.GetField("name")
                        If tempname Like "DX*" Then
                            'Print clip
                            count += 1
                        ElseIf tempname = "Stor" Then
                            'Need more information for the EMC01 records
                            clipRef = thePool.ClipOpen(queryResult.ClipID, FPMisc.OPEN_FLAT)
                        

                           clipRef.Close() 'closes all resources associated with clip
                        ElseIf tempname Like "Kvs*" Or tempname Like "SColl*" Then
                            'Print clip
                            count += 1
                        Else
                            'its some other sort of clip, so just write out what we know
                            count += 1
                        End If

                    ElseIf queryStatus = FPMisc.QUERY_RESULT_CODE_INCOMPLETE Then
                        ' Error occured one or more nodes on centera could not be queried.
                        Console.WriteLine("Received FP_QUERY_RESULT_CODE_INCOMPLETE error, invalid C-Clip, trying again.")

                    ElseIf queryStatus = FPMisc.QUERY_RESULT_CODE_COMPLETE Then
                        ' Indicate error should have been received after incomplete error
                        Console.WriteLine(("Received FP_QUERY_RESULT_CODE_COMPLETE, there should have been a previous " + "FP_QUERY_RESULT_CODE_INCOMPLETE error reported."))

                    ElseIf queryStatus = FPMisc.QUERY_RESULT_CODE_ERROR Then
                        'Server error
                        Console.WriteLine("received FP_QUERY_RESULT_CODE_ERROR error, retrying again")

                    ElseIf queryStatus = FPMisc.QUERY_RESULT_CODE_PROGRESS Then
                        Console.WriteLine("received FP_QUERY_RESULT_CODE_PROGRESS, continuing.")

                    Else
                        ' Unknown error, stop running query
                        Console.WriteLine(("Aborting - received unkown error: " + queryStatus))
                        Exit While

                    End If
                    queryStatus = myQuery.FetchResult(queryResult, -1)

                    pcount += 1
                    tcount += 1
                    If pcount > 499 Then
                        Console.WriteLine("Clips read:" + tcount.ToString())
                        pcount = 0
                    End If
                End While

0 Kudos
3 Replies
gstuartemc
2 Iron

Re: Memory Leak

The Close method for a clip closes the underlying FPClipRef of the Centera SDK, i tmay be that it is not disposing of the object.

Try a using clause or use Dispose rather than Close.

Are you aware that if the attributes that you wish to examine are clip level (rather than tag level) then they can be retrieved as part of the query result, and you would not have to open the clips in question?

0 Kudos

Re: Memory Leak

so is a dispose and a close required:

tg.Dispose()

clipRef.Dispose()

With out clipref.dispose or clipref.close
System.AccessViolationException was unhandled
  Message="Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
  Source="mscorlib"
  StackTrace:
       at System.StubHelpers.ValueClassMarshaler.ClearNative(IntPtr dst, IntPtr pMT)
       at EMC.Centera.FPApi.SDK.FPPool_GetLastErrorInfo(FPErrorInfo& outErrorInfo)
       at EMC.Centera.FPApi.SDK.CheckAndThrowError()
       at EMC.Centera.FPApi.Pool.Close(FPPoolRef inPool)
       at EMC.Centera.SDK.FPPool.Close()
       at EMC.Centera.SDK.FPObject.Dispose(Boolean disposing)
       at EMC.Centera.SDK.FPObject.Finalize()
  InnerException:

with clipref.close()
System.AccessViolationException was unhandled
  Message="Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
  Source="mscorlib"
  StackTrace:
       at System.StubHelpers.ValueClassMarshaler.ClearNative(IntPtr dst, IntPtr pMT)    at EMC.Centera.FPApi.SDK.FPPool_GetLastErrorInfo(FPErrorInfo& outErrorInfo)    at EMC.Centera.FPApi.SDK.CheckAndThrowError()    at EMC.Centera.FPApi.Clip.Close(FPClipRef inClip)    at EMC.Centera.SDK.FPClip.Close()    at VBQueryCluster.QueryCluster.QueryCluster.Main(String[] args) in C:\EMC\SDK\samples\VBQueryCluster\QueryCluster.vb:line 134    at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)    at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)    at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)    at System.Threading.ThreadHelper.ThreadStart()
  InnerException:

with clipref.dispose()
System.AccessViolationException was unhandled
  Message="Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
  Source="mscorlib"
  StackTrace:
       at System.StubHelpers.ValueClassMarshaler.ClearNative(IntPtr dst, IntPtr pMT)    at EMC.Centera.FPApi.SDK.FPPool_GetLastErrorInfo(FPErrorInfo& outErrorInfo)    at EMC.Centera.FPApi.SDK.CheckAndThrowError()    at EMC.Centera.FPApi.Clip.Close(FPClipRef inClip)    at EMC.Centera.SDK.FPClip.Close()    at EMC.Centera.SDK.FPObject.Dispose(Boolean disposing)    at EMC.Centera.SDK.FPObject.Dispose()    at VBQueryCluster.QueryCluster.QueryCluster.Main(String[] args) in C:\EMC\SDK\samples\VBQueryCluster\QueryCluster.vb:line 134    at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)    at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)    at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)    at System.Threading.ThreadHelper.ThreadStart()
  InnerException:

The attribute that I am looking for is #12 - for the name of the tag, since the clip has a generic one and the tag tells me more on which applicaiton wrote to the Centera.

If queryStatus = FPMisc.QUERY_RESULT_CODE_OK Then
      tempname = queryResult.GetField("name")
      If tempname Like "DX_FILE_CLIP*" Then
      ElseIf tempname = "Storigen_File_Gateway" Then
           clipRef = thePool.ClipOpen(queryResult.ClipID, FPMisc.OPEN_FLAT)
            tg = clipRef.Tags(1)
           If tg.Attributes(12).value Like "*sfs/gateway_cifs*" Then
           ElseIf tg.Attributes(12).value Like "*sfs/gateway_nfs*" Then
            End If
            tg.Dispose()
            clipRef.close()'closes all resources associated with clip
      End If

end if
queryStatus = myQuery.FetchResult(queryResult, -1)

      

0 Kudos
gstuartemc
2 Iron

Re: Memory Leak

No, a Dispose alone is sufficient (as it calls Close - which you can see in the wrapper code you downloaded).

You are disposing of the Tag then closing the Clip. Dispose of both.

The errors you ar egetting are not "normal" SDK errors. Have you downloaded the latest version of the wrapper and successfuly built it under .NET Framework 3.0 (or 3.5)?

Does the VBQeuryCluster sample work properly and does it show any memory leak?

0 Kudos