1 Reply Latest reply on Jul 3, 2018 12:26 PM by Eric Snyder

    Issues with memory climbing as I load files - Memory leak?

    Eric Snyder

      I have a VB.NET app that iterates over a set of paths and opens files. Once the files are open I iterate the features and then close all docs. MY issue is that after some point the app just locks up. There are no loops that could become infinite loops. I left it to run overnight and it was locked up. When I check memory usage on the Solidworks process it was using 3,567,915 k or so.

       

      I terminated the session of Solidworks, restarted manually and reloaded the file it was hung on. The new session of Solidworks was using about 500,000k memory or so.

       

      The code is too long to post but I basically do this in pseudo code:

       

      Get list of file using System directory services.

      Filter some files out of the list for various reasons.

      Open Solidworks by using:

      swApp = New SldWorks.SldWorks

       

      Iterate the file paths

              If File.Exists(path) Then

                  Select Case System.IO.Path.GetExtension(path).ToUpper

                      Case ".SLDASM"

                          docType = swDocumentTypes_e.swDocASSEMBLY

                      Case "SLDPRT"

                          docType = swDocumentTypes_e.swDocPART

                      Case Else

                          Return Nothing

                  End Select

                  swPart = swApp.OpenDoc6(path, docType, swOpenDocOptions_e.swOpenDocOptions_Silent, "", errors, warnings)

       

                  Get some data from the file

                  Close the file using:

                  swApp.CloseAllDocuments(True)

      End iteration

      Is there some kind of garbage collecting I need to be doing?

      Anybody have any ideas?

       

      EDIT: By the way...If I open a new session of Solidworks it takes up something like 150,000K of memory.

      Windows 7 Pro 64bit machine

      16G ram

      Solidworks 2018 SP 0

        • Re: Issues with memory climbing as I load files - Memory leak?
          Eric Snyder

          I put a bunch of logging commands. It looks like my app has been hung on:

                          swApp.ExitApp()

          The command was issued 30 minutes ago and is stuck there. It's almost like the app is waiting for a prompt but I can't see it because the prompt app is running in the background. The SLDWORKS.exe process has 1,136,100k of memory allocated - way more than I would expect if all the files are closed.