Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy Analyzer reserves over 9Gb of memory

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Strategy Analyzer reserves over 9Gb of memory

    Hi,

    During past weeks I have been running quite heavy backtests with NT8 B11 and B12 to an instrument list with some hundreds of symbols. I have experienced that the Strategy Analyzer accumulates the usage of memory without releasing it. Strategy Analyzer eats already 9,5Gb of memory and restarting NT8 or booting the computer does not release the memory from Strategy Analyzer.

    Here’s some observations I have made:
    1) Strategy Analyzer accumulates the usage of memory slowly. Each backtest will cause the Strategy Analyzer to reserve more memory. Complexity of the backtested strategy will contribute to "how fast and how much" accumulation will happen. In general, problem gets worse by time until NT8 comes very slow.
    2) If I close the Strategy Analyzer window memory is released temporarily, but when I start it again it reserves the same amount of memory that was reserved in the past before restart. In my case that’s 9,5 Gb and growing.
    3) If a Strategy Analyzer window that already reserves a lot of memory has been saved with default workspace opens in the startup of NT, the startup of NT will become 30-60+ times slower.
    4) Opening the Strategy Analyzer alone (in this bad state) will also use a lot of computing power. I have an i7 with 6 cores @ 4,5GHz and opening the Analyzer consumes 75% of my computing power for ca. 20-30 sec. After the Startegy Analyzer startup the CPU consumption will go down back to normal. However NT will response slowly as long as the Strategy Analyzer window is open.
    5) I am using NT8 on two computers. Both computers have the same problem. My friend had NT8 running on virtual computer and he had this problem too.
    6) Going from NT8 version B10 to B11 or from B11 to B12 did not help.

    Why is this happening? Is there a way to release the memory from the Analyzer?

    Thanks,

    Reiska
    Last edited by Reiska; 07-27-2016, 05:21 AM.

    #2
    How much historical data do you have?

    9 GBs?

    Comment


      #3
      Hi sledge,

      Thanks for your response. NinjaTrader 8\db folder size is ca. 7,1 Gb and size on disk is ca. 12Gb ", where cache folder size is 4,1 Gb and size on disk is 6,5 Gb. So I have 3Gb/ 5,5Gb of historical data (tick, minute & daily).

      Reiska

      Comment


        #4
        Hello Reiska,

        This is likely due to the strategy objects being constructed in the script in either the scope of the class or the scope of OnStateChange.

        Please, try closing all of your workspaces and then restart NinjaTrader. Open a new Strategy Analyzer and backtest the Sample MA CrossOver using any instrument.
        After running this simple backtest, are you seeing that the NinjaTrader process in the Task Manager (by itself) is using a very large amount of memory?

        I can confirm that the memory used for NinjaTrader is released when NinjaTrader is closed.
        However, when the workspace opens, the strategy analyzer must construct the strategy making any objects that are created as the script is constructed and then the script will also run OnStateChange with SetDefaults. The actual backtest is not run, the historical data is not loaded (until an actual backtest is run), and the saved results are loaded (instead of a backtest being performed).

        So the script itself does need to load into memory as the workspace opens, and this is likely where the heavy resource use is coming from.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hello Chelsea,

          I did as per your instructions. Closed all the windows, opened a new Strategy Analyzer, ran the Sample MA crossover strategy fora a single symbol. Saved the Sample MA crossover strategy as default. No change. Was still eating 9.5Gb.
          Then...
          1) I closed the Strategy Analyzer -> memory released.
          2) Closed NT and saved the workspace having only the Control Center open.
          3) Restarted NT -> memory consumption 117Mb
          4) Opened Strategy Analyzer -> memory consumption 9,7Gb! :| Wow
          However I expected NT to open the Sample MA crossover as default, but it didn't, it opened one of my custom strategies. I reopened the Sample MA crossover but it didn't have any effect on the memory consumption.

          Reiska

          Comment


            #6
            Hello Reiska,

            To close a workspace, on the Control Center click Workspaces -> hover the mouse over an open workspace -> click Close. Repeat this for all open workspaces. (This allows you to keep your workspace and have it closed for this test)

            However, I'm thinking about it more and the moment the Strategy Analyzer is opened, the constructors and OnStateChange for all strategies are run. This means if the issue is a strategy creating objects when constructed or in OnStateChange then this would still be an issue even in a blank workspace.

            So just closing the workspace isn't enough, the scripts would need to be temporarily moved outside of NinjaTrader.

            In this case, I would want you to create a new 'Documents\NinjaTrader 8' folder and test the Sample MA crossover strategy without any other strategies in the list.
            (All strategies are constructed when the Strategy Analyzer window opens and when the Strategies window from a chart is opened.)

            To recreate the 'Documents\NinjaTrader 8' folder:
            1. Shutdown NinjaTrader
            2. Rename 'Documents\NinjaTrader 8' to 'Documents\NinjaTrader 8.old'
            3. Run the installer for NinjaTrader 8, and select Repair to regenerate the settings folder
            4. Then copy 'Documents\NinjaTrader 8\config.xml' to 'Documents\NinjaTrader 8\'
            5. Then start NinjaTrader 8 and test for the behavior once more without the scripts


            (The next steps will be to add the strategies back one at a time to see if there is one in particular that is causing an issue.)

            First, however, I'd like to know if the high memory usage still occurs without any custom or 3rd party strategies imported.

            If you would like assistance with this process, please send an email to platformsupport [at] ninjatrader [dot] com. In the email include a link to this forum thread.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7

              Comment


                #8
                You are keeping 10000 best results?? That will cause some big memory consumption if you have many trades per configuration in the optimization.

                Comment


                  #9
                  Hello sashe71,

                  When optimizing to reduce memory consumption you will need to adjust your script to use IsInstantiatedOnEachOptimizationIteration set to false.


                  This means that all variables should not be instantiated in #region variables where they are declared, but instead instantiated in to their initial values in State.DataLoaded (or State.Historical) after the script begins testing.
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #10
                    Hi ChelseaB, all,

                    I apologize for my late answer. I was on holiday and away from my computer for two weeks.

                    However I did some further investigation and found out that the Startegy Analyzer had collected a huge log into 'Documents\NinjaTrader 8'_> StrategyAnalyzerLog (also seen via Script Editor as a sparate file under Strategies). The log file had ca. 35000 files/ 7GB in it. I dumped the content of StrategyAnalyzerLog in to a seperate backup folder. Idle memory usage dropped from 9GB to ca. 200M.

                    Reiska

                    Comment


                      #11
                      Hello Reiska,

                      I'd like to give this a test, however, I am uncertain how to make this many log files.

                      Have you run 35,000 backtests? Are these logs being generated without running this many backtests?
                      Chelsea B.NinjaTrader Customer Service

                      Comment


                        #12
                        Hi ChelseaB,

                        I have been running backtests on a instrument list with ca. 1800 symbols on it. NT8 creates the same amount of XML-files (containing used strategy parameters and performance data) in to the log per each backtest done on the instrument list.

                        I.e. in my case each backtest creates 1800 XML-files and all of those have exactly the same date and time stamp on it.

                        Reiska

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by GussJ, 03-04-2020, 03:11 PM
                        16 responses
                        3,281 views
                        0 likes
                        Last Post Leafcutter  
                        Started by WHICKED, Today, 12:45 PM
                        2 responses
                        19 views
                        0 likes
                        Last Post WHICKED
                        by WHICKED
                         
                        Started by Tim-c, Today, 02:10 PM
                        1 response
                        9 views
                        0 likes
                        Last Post NinjaTrader_ChelseaB  
                        Started by Taddypole, Today, 02:47 PM
                        0 responses
                        5 views
                        0 likes
                        Last Post Taddypole  
                        Started by chbruno, 04-24-2024, 04:10 PM
                        4 responses
                        53 views
                        0 likes
                        Last Post chbruno
                        by chbruno
                         
                        Working...
                        X