Forum Discussion

stevepac's avatar
stevepac
Occasional Contributor
15 years ago

Is there any code that I could use to clear memory?

I have been trying to write a little script for testing a windows mobile software and I have noticed that whenever  the script does something, the memory usage of testcomplete 7 keeps increasing and crashes eventually. The following is a little example using bubble breaker.

function Main()

{

    Log.LockEvents();

    var BB =
WinCETestedApps.BubbleBreaker.Run();

    while (true)

    {

        
BB.Refresh();

        var picture = BB["Window"]("Bubble Breaker").Picture();

    }

}



For each loop, the memory usage keeps increasing until it reached 1.6gb and finally crashed.

I even turned off events to see if it was the log that keeps building up but it wasn't.

I also tried the above code with an windows application and seems that the memory usage does not increase as much as when run on a windows mobile application.


Is there any particular reason for this or is it just a memory leak problem that needs to be fixed?

Is there any code that I could use to clear memory?


Thanks







 



 



 

 


 



 



9 Replies

  • stevepac's avatar
    stevepac
    Occasional Contributor
    I just found that while the above script is running, if I minimise testcomplete window the memory gets cleared up.

    Perhaps this is something that can be fixed in the future?
  • stevepac's avatar
    stevepac
    Occasional Contributor
    Sorry it was a false discovery. it was not actually letting go of the memory it was using.

    Even though the memory usage of TestComplete dropped from 1.6gb to 20mb, the available memory was still not reclaimed and stayed unchanged.
  • Hi Stephen,



    Try to reproduce the problem with the latest version of TestComplete (7.52). Also, try to reproduce the problem by using the modified routine:

    function Main()


    {


        Log.LockEvents();


        var picture = null;


        var BB = WinCETestedApps.BubbleBreaker.Run();


        while (true)


        {


            picture = BB["Window"]("Bubble Breaker").Picture();


        }


    }


    Let me know your results.



    Also, please specify the model and vendor of the PDA you are using and let me know whether it is emulated.
  • stevepac's avatar
    stevepac
    Occasional Contributor
    Hi David



    Thanks for your response.

    I have the latest TC which is 7.5.2.

    Your code still behaves the same and I also tried to nullify all the variables before and after within the loop by doing the following:



    function test()

    {

        Log.LockEvents();

        while (true)

        {

            var BB = null;

            var picture = null;

            BB = WinCETestedApps.BubbleBreaker.Run();

            picture = BB["Window"]("Bubble Breaker").Picture();

            picture = null;

            BB = null;

        }

    }



    I have Samsung Omnia 2 I8000 as a test phone.

    Thanks


  • Hi Stephen,




    We were unable to reproduce the problem.




    Let me know whether the problem is reproducible when the following routine is executed (before executing, run Notepad):




    [JScript]




    function Main()

    {

        var picture = null;

        while (true) {

            picture = Sys.Process("notepad").Window("Notepad", "Untitled - Notepad", 1).Picture();

        }

    }




    Also, to help us investigate the problem, please follow the steps below:




    1. Download a free trial version of AQtime 6, which is our profiling tool, from our web site. The trial can be requested on the following page of our web site:





    2. Install the tool.




    3. Start AQtime.




    4. Select the 'File | New Project From Module...' main menu item.




    5. In the Open File dialog, select the TestComplete.exe file and click Open.




    6. Take a look at the AQtime toolbar - there is a combo box. Open it and select the "Tracing | Exception Trace Profiler" item.




    7. Select the "Options | Options..." main menu command - the Options dialog will appear.




    8. Set the "Profiling Time | Event View | General | Exceptions | Depth shown" setting to 100 and click OK.




    9. Start TestComplete.




    10. Click the Run | Attach to Process... main menu item in AQtime.




    11. Select the TestComplete.exe process from the list by double-clicking it and click Run in the dialog that appears after that.




    12. Reproduce the problem in TestComplete.




    13. After the problem occurs, right-click somewhere within the Event View panel (it is opened by default at the bottom of AQtime's window) and select the 'Save All...' item.




    14. Save the panel's contents to an HTML file and send me the file via our Contact Support form:





    Thanks in advance.

  • stevepac's avatar
    stevepac
    Occasional Contributor
    Hi Alex



    Thank you for your response.



    This memory-increasing issue only occurs when running the code on Windows Mobile Application on the actual device.

    It does not happen with windows application such as notepad.

    I am not sure if it also occurs on Windows Mobile emulator, but I suggest you to try it on an actual windows mobile device, if you have access to one.



    I will try the AQTime in a short moment - thanks for the detailed steps.



    Cheers
  • scsvel's avatar
    scsvel
    Frequent Contributor
    Hi Alex,

    I need a code snippet that can clear all the memory alloted and data. I want to use this code snippet between every case in my driver script at start of each test case so that my TC won't crash.. 



    Thanks...
  • scsvel's avatar
    scsvel
    Frequent Contributor
    Hi all,



    Please  give me an answer...



    thx...

  • Hi Shanmugavel,





    I want to use this code snippet between every case in my driver script at start of each test case so that my TC won't crash


    This thread is quite old and is related to an obsolete version of TestComplete. So, first of all, please check whether the crashes can be reproduced on the latest version of TestComplete (currently, ver. 8.20). You can apply for a free trial version of TestComplete 8.20 here.