10 Replies Latest reply: Apr 26, 2012 10:39 PM by AshishSharma RSS

    GetValue works slow in a complex and bulky sheet..

    AshishSharma Bronze

      Hello all,

        

      GetValue function is working as expected when I read simple to medium complex worksheet in my external java program but its taking around 3-4sec for every GetValue when I read some bulky and complex worksheet like 15MB in size (I checked both save/do not save large results in xml but result is same). I can not post the worksheet here due to IP issues.

       

      Its quite annoying when sheet has 100s of variables in it. Moreover it hangs for indefinite time at GetValue of any random variable. The more confusion in that the variable while getting value of which application hung last time gives value next time.

       

      Any suggesions that I can make it work and faster?

       

      Thanks & Regards,

      Ashish

        • Re: GetValue works slow in a complex and bulky sheet..
          A.Non PTC Community Champion

          GetValue function is working as expected when I read simple to medium complex worksheet in my external java program but its taking around 3-4sec for every GetValue when I read some bulky and complex worksheet like 15MB in size (I checked both save/do not save large results in xml but result is same).

          How long does it take the worksheet to calculate? You can't possibly get the values faster than that, and in practice there will of course also be some overhead.

           

          I assume you are only loading the worksheet once, and then getting all the values!

           

           

          Moreover it hangs for indefinite time at GetValue of any random variable. The more confusion in that the variable while getting value of which application hung last time gives value next time.

          When you say it hangs for an indefintie time do you mean it eventually recovers, or does it never give you the value? This sounds like a bug to me.

            • Re: GetValue works slow in a complex and bulky sheet..
              AshishSharma Bronze

              How long does it take the worksheet to calculate? You can't possibly get the values faster than that, and in practice there will of course also be some overhead.

              I assume you are only loading the worksheet once, and then getting all the values!

              Its taking around 5sec approx to calculate the worksheet. So do you mean to say the worksheet is implicitly recalculated each time I call GetValue? I supposed calculate should happen only first time. Yes I am opening the worksheet just once and then calling GetValue on all the 300 variables its having.

              When you say it hangs for an indefintie time do you mean it eventually recovers, or does it never give you the value? This sounds like a bug to me.

              No, it does not recovers. Earlier what I had faced, due to memory leak I was facing troubles when virtual size of Mathcad was getting real close to 2GB in my 32 bit XP Professional (That time I had to open - close multiple worksheets , one after another,  with same instance of Mathcad application). I resolved this by restarting Mathcad application programatically. But now this time when Mathcad stops responding is NOT closer to 2BG, it is happening at random around 1GB or some more(this time I am calling GetValue for hundreds of variables on same worksheet open and same Mathcad instance). Yes memory leak is there but surely there is more scope to it, its not reaching to max allowed value and getting unresponsive much earlier.

               

              - Ashish

                • Re: GetValue works slow in a complex and bulky sheet..
                  A.Non PTC Community Champion

                  Its taking around 5sec approx to calculate the worksheet. So do you mean to say the worksheet is implicitly recalculated each time I call GetValue?

                  No, that's not what I meant. I meant only that if it takes, for example, 10 minutes, to calculate the entire worksheet, then it will take that long to get a variable at the end of the sheet, and maybe even at the beginning. I really hope it is not recalculating the entire sheet for every GetValue, and I don't think that is the case! You cold test that though. Put a very long calculation (for example a loop that executes millions of times)  at the start of the sheet, and see what happens to the timings.

                   

                   

                  No, it does not recovers.

                  That has to be a bug then. There's no good reason I can think of what GetValue would not work with a random number.

                    • Re: GetValue works slow in a complex and bulky sheet..
                      AshishSharma Bronze

                      Hello Richard,

                       

                      I followed your suggestions of having a big loop and relate the program behavior, in this case and using the same code of program I observed only first GetValue takes time as worksheet is calculated and all other GetValue works really fast. So does this mean in my earlier case with bulky file the worksheet was getting calculated in parts or recalculated? I mean I can't come to conclusion for this behavior

                       

                      Can you please tell me what is average size of Mathcad worksheet that companies do have in real world COMPLEX scenario? This is just for information.

                       

                      Also I want to ask one more thing, as the Mathcad application was becoming unresponsive at GetValue of somewhere between 150-250 variables at random, what I tried is, I try to close Mathcad application after every 100th GetValue using Quit and mcDiscardChanges. This closes Mathcad sometimes but sometimes only the child process of Mathcad(MS Excel- excel sheets are embeded in the xmcd) gets closed but not the actual Mathcad application. Do you see any reason or solution for this?

                      • Re: GetValue works slow in a complex and bulky sheet..
                        AshishSharma Bronze

                        Hello Richard,

                        Hope you are doing well.

                        Can you please reply to my msg wrote on 21st Feb?

                  • Re: GetValue works slow in a complex and bulky sheet..
                    jsheehan PTC Employee

                    Ashish

                    What version are you on? There were memory leaks in versions of Mathcad 14 which showed themselves through the automation interfaces (GetValue).

                    John

                      • Re: GetValue works slow in a complex and bulky sheet..
                        AshishSharma Bronze

                        Yes, I am using Mathcad 14.0 M020 (14.0.2.5 [802141434]). But if you saying about memory leaks in Mathcad itself I was believing its not due to Mathcad but due to jacob.dll which is a Java-com bridge to communciate with windows applications. I concluded this as when I tried callling 300 GetValue from VBScript, Mathcad is not stopping and gives all values. But yes this time also the speed is same 3-4 sec on avg. for each GetValue, means 300 * 3 Sec = 900 sec to get values of all variable.. which is too much I think..

                        Any light on this??

                         

                        - Ashish

                      • Re: GetValue works slow in a complex and bulky sheet..
                        MichaelH Silver

                        Why don't you just pack an array in Mathcad with all the values and then just pass the array to the script using an input variable?

                         

                        The process can be reversed using an output variable to get the array out if necessary.