6 Replies Latest reply on Nov 22, 2012 3:18 AM by Rajat Jain

    RAM and concurrency handling

    Nozze Feduti

      So, I'm wondering how SolidWorks works =) under the hood.

       

      How can I release RAM allocated for opening and managing a document, after it has been closed?

       

      Is there a way to start a new SLDWORKS.exe (in background) instead of attaching to existing one running in background?

       

      How SolidWorks handles concurrency during operation? e.g. I've two opened documents and through API I wanna save them in a specific format.

      Sometimes one of the two operations is just ignored. I don't know the specific sequential order of the operations, 'cause they are teorically concurrent.

       

      Hope you'll understand my english...pls help.

       

      Many thanks, bye.

        • Re: RAM and concurrency handling
          Artem Taturevych

          How can I release RAM allocated for opening and managing a document, after it has been closed?

           

          Try to force release the COM pointers to your documents. If you in .NET use Marshal::ReleaseComObject

           

          Is there a way to start a new SLDWORKS.exe (in background) instead of attaching to existing one running in background?

           

          Start new instance by starting a new process. I didn't found a way to start new instance as COM server i.e. using ::CreateInstance.

           

          How SolidWorks handles concurrency during operation? e.g. I've two opened documents and through API I wanna save them in a specific format.

          Sometimes one of the two operations is just ignored. I don't know the specific sequential order of the operations, 'cause they are teorically concurrent.

          I think this is internal stuff which doesn't open to users (I may be wrong). Is that correct that you are trying to work with your SolidWorks documents asynchronously?

          ______________________

          Regards,

          Artem Taturevych

          Application Engineer at Intercad

          http://intercad.com.au/

          Tel: +61 2 9454 4444

            • Re: RAM and concurrency handling
              Nozze Feduti

              Thanks for your time Artem.

               

              I'm using Marshall::ReleaseComObject to release components like Model, ModelExt, etc. and finally the FinalReleaseComObject for the whole swApp. Anyway until I release the app, no memory is freed for the components.

               

              Unfortunately I need a COM server running in background...

               

              https://forum.solidworks.com/thread/49344

               

              this guy talking about a solution, but he doesn't say how to run it in background and it seems to be the hard way.

               

              I'm trying to expose on the web X3D models requested at runtime to the 3D engine, so multiple requests can come across the net. Any advice about a smart architecture? Should I serve client sequentially to avoid concurrency?

                • Re: RAM and concurrency handling
                  Artem Taturevych

                  What you mean by background? Make the app invisible or decrease the priority of the process? If first one set the SldWorks::Visible property to False. If second one use .NET Framework/WinAPIs to change the process priority.

                   

                  What about your question. You definitely should use the queue for your clients supporting X concurrent SolidWorks session may be run at a time to process several requests simultaneously however based on server resources this number of instances may be different.

                   

                  I'm not exactly sure but for this scenario you may need a network license of SolidWorks (if you do not have one already) because your web-service became a proxy server and you are going to run several instances at a time to process several clients. I would suggest to clarify this with API support guys.

                   

                  About the ram. How do you measure the memory leaks so you know that the resources are not released when document is closed? Are you sure that this is the model resources but not application ones?

                  ______________________

                  Regards,

                  Artem Taturevych

                  Application Engineer at Intercad

                  http://intercad.com.au/

                  Tel: +61 2 9454 4444

                  • Re: RAM and concurrency handling
                    Rajat Jain

                    Nozze,

                     

                    I'm using Marshall::ReleaseComObject to release components like Model, ModelExt, etc. and finally the FinalReleaseComObject for the whole swApp. Anyway until I release the app, no memory is freed for the components.

                     

                    This is a known behavior with SolidWorks. The models remain loaded in session unless the application object is dumped (which means the session is closed).

                     

                    Unfortunately I need a COM server running in background...

                     

                    https://forum.solidworks.com/thread/49344

                     

                    this guy talking about a solution, but he doesn't say how to run it in background and it seems to be the hard way.

                     

                    Starting new sessions is possible with SolidWorks (although it pops up the Journal file error). You can still use sldWorks::UserControl and sldworks::UserControlBackground() to set the background process.


                    I'm trying to expose on the web X3D models requested at runtime to the 3D engine, so multiple requests can come across the net. Any advice about a smart architecture? Should I serve client sequentially to avoid concurrency?

                     

                    I think a discussion on smart architecture is possible once your current requirement is completely understood. If you can share more details then probably we can support you with architecture. Additionally, please do mention your programming language and SolidWorks versions supported.

                     

                    Hope it helps!!!

                     

                    Rajat Jain

                      • Re: RAM and concurrency handling
                        Nozze Feduti

                        I'll try to be more clear and precise.

                         

                        1. I'm using SolidWorks 2012 and C#, Win 7 64 bit.

                         

                        2. With process in background I mean not visible.

                         

                        3. I'm watching RAM allocated for SLDWORKS.exe in the task manager.

                         

                        4. Scenario: I've a background running session of SolidWorks. Afterwards I want to start a different background session without attaching to the existing one. Doing:

                         

                        SldWorks swApp1 = new swApp1();

                        SldWorks swApp2 = new swApp2();

                         

                            will fail (attaching swApp2 to existing SLDWORKS.exe). Can you please provide a snippet of code using sldworks::UserControlBackground()?

                         

                        5. Architecture: my aim is to design a configurator.

                        More specifically a client sends to the server some quota values belonging to an assembly.

                        Server-side SolidWorks opens up the corresponding assembly (with default quota values), set quota sent from client, calculate new geometry and send it (in VRML format) back to the client.

                         

                        5bis. I think a single session of SolidWorks cannot handle architecture described in 4.

                        I'm thinking about two possible solutions:

                         

                        - Serve one client request at a time, each time creating a new SolidWorks instance, then destroying it and go to the next request.

                        - Create multiple SLDWORKS instances, each one serving a specific client request. This one is surely better, but I've problems described above.

                         

                        Hope I've been more clear and thanks for reading.

                          • Re: RAM and concurrency handling
                            Rajat Jain

                            Nozze,

                             

                            I think I understand what you want to develop now. I am not sure but I do not see any issues with a single session SolidWorks Application running on the server. The start of this SW application instance, processing, closing, and scheduling process of each client input can be handled independently by a service.

                             

                            Having said this, if you still insist on starting multiple instances of SolidWorks, I am sure it can be done. In VB, we can use the CreateObject() function to start individual instances of SW. Since I have a limited knowhow in C#, I am not sure about the corresponding function.

                             

                            I'm thinking about two possible solutions:

                             

                            - Serve one client request at a time, each time creating a new SolidWorks instance, then destroying it and go to the next request.

                            - Create multiple SLDWORKS instances, each one serving a specific client request. This one is surely better, but I've problems described above.

                             

                            I think that the  first choice is better architecture. I have myself experienced many issues with Solidworks (in earlier versions) when more than 1 instance of SW runs on a machine. To improve the performance in the first case, your service may not close SW unless all inputs are processed.

                             

                            I have created a similar structure in past where in we had a web service which would trigger the processing on SW and close it when no more inputs are left. If you need any support in this regard, please mail me at rajatjain.iitd[at]gmail.com

                             

                            Hope it helps!!!

                             

                            Rajat Jain