Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Minimizing memory usage

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

    Minimizing memory usage

    I have a more general question concerning memory being eaten up by drawing objects in NT7 and what is the best way to minimize memory usage. I read the information on MaximumBarsLookBack and the term "significant memory savings" caught my attention.



    For example I have a rectangle being drawn in every current bar, let's say a 5min DataSeries. I am only interested in the current bar's rectangle. Thus my tag name for drawing the rectangle does not include ... "+CurrentBar".

    I have an extra bool which when switched on shows all the past bars' rectangles with "mytag + CurrentBar". But I do not have it On during normal live operation.

    How does this affect memory usage? Does it keep creating and storing these past rectangles so they are available when I want to see them, or does it only create them when I want to see them.

    Should I get rid of this bool altogether and then add "if (Historical) return;" in the OnBarUpdate section. Or should/could I use MaximumBarsLookBack.TwoHundredFiftySix here to make a difference in memory savings?

    And is there something within NT7 that shows memory usage? I know of the two SDF files in the db folder of NT. As of today NinjaTrader.Old has 19,016KB; NinjaTrader has 14,768KB. What do these numbers mean? Are they "normal"? Is there a size which can cause slower performance?

    I would appreciate if someone could shed some light for me on these things.

    sandman

    #2
    Hello sandman,

    Thank you for your post.

    You can observe the Memory Usage in the Windows Task Manager. Please right click on your Windows Task Bar and select Task Manager. Go to the Processes tab and locate the 'ninajtrader.exe' process.

    Drawing Objects remain in memory on the chart when drawn by a NinjaScript Object. It general if a large number of drawings are needed we would recommend the use of custom plotting instead - which will draw the objects on the available view-able area instead. You can find an example of custom plotting under Tools > Edit NinjaScript > CustomPlotSample.

    You can also review our performance tips for more information: https://ninjatrader.com/support/help...ance_tips2.htm

    Please let me know if you have any questions.

    Comment


      #3
      Patrick.
      Thanks. The Windows Task Manager showed a usage of about 135,000K.
      It gradually went up and when it went over 250,000K my charts started to hang up (though the Phsycial Memory under the Performance Tab of the TaskManager still shows 1,250MB Free).

      What's a normal or average usage size here so I may have an orientation point.

      sandman

      Comment


        #4
        Hello sandman,

        Thank you for your response.

        This would depend on a few factors but roughly let's say a single bare chart is looking somewhere around 100 MB in Memory usage (including the Control Center and the active connection).

        Every window, NinjaScript object (indicators, strategy, etc.), Drawing Object, etc. all increase memory usage.

        You can improve the overall performance of NinjaTrader by implementing our performance tips from the following link: http://www.ninjatrader.com/support/h...ance_tips2.htm
        Some key items to focus on when it comes to charting are the following:
        • The DaysToLoad/BarsToLoad setting for your charts can be reduced to improve performance. This option is viewed when right clicking in your chart > selecting Data Series. For information on working with Price Data please visit the following link: http://www.ninjatrader.com/support/h...price_data.htm
        • The indicators on the chart have two options that can be set to improve performance. The CalculateOnBarClose option can be set to True to improve performance, and the MaximumBarsLookBack can be set to TwoHundredFiftySix (which is the default setting).
        • When right clicking in the chart and selecting Properties, you will find an option called Update Display Interval. This can be set to a higher value on charts you may not be viewing at all times to help improve performance. This will only delay the visual update and not the actual data or calculations of indicators or strategies.

        There is no one option to improve performance, and you may only need to use one of these settings on one chart.

        Please let me know if I may be of further assistance

        Comment


          #5
          Patrick.

          Thanks. I am familiar with the options you laid out.

          Let me put my question differently. I enclose three screen shots to clarify what I mean.

          1. I start NT7 with a workspace that includes only 1 chart with no indicators at all. The Windows Task Manager shows a usage of 68Mb. See first image.

          2. I open a new workspace with several charts and indicators. Usage now jumps up to 102Mb. See second image.

          3. I close that workspace again; I do not switch to the previous one; I actually close it. See third image. Although closed, not active, killed, usage by NT remains at 102Mb. WHY? When I started with that one first chart 68Mb were sufficient to run that one chart with no indicators. Why does NT now use 102Mb to do that same thing. Where are these 34Mb being used when I factually closed that workspace? And most importantly, how do I free them up again?

          Edited by adding:
          Same phenomenon shows up when:
          a) I start NT with 1 workspace, 1 chart, no indicators > usage is around 63,000K

          b) then go into editing an indicator > usage increases to about 120,000K which is to be expected.

          c) I compile and close the editor > usage continues to show 120,000K when I would expect it to now drop again to 63,000. After all I just have that one chart with no indicators open and running. Where is the difference of about 60,000K being used/eaten up, and how do I free them up again?

          sandman
          Attached Files
          Last edited by sandman; 02-05-2018, 10:08 AM.

          Comment


            #6
            Originally posted by sandman View Post
            Patrick.
            Thanks. The Windows Task Manager showed a usage of about 135,000K.
            It gradually went up and when it went over 250,000K my charts started to hang up (though the Phsycial Memory under the Performance Tab of the TaskManager still shows 1,250MB Free).

            What's a normal or average usage size here so I may have an orientation point.

            sandman
            You should be fine within those parameters. I wouldn't expect freezing at 300k, or even 1000k
            .
            Is this is charts only?

            Do you have any special indicators? Or are those indicators NT supplied indicators? Do the problems go away removing the indicators?

            Do you refresh a lot?

            I looked at my NT7 after startup tonight, 102K tonight.6 charts, 1 market analyzer, 1 dom, 1 output window.

            I only restart weekly. (TDA/Rithmic connections).

            Comment


              #7
              Hello sandman,

              Thank you for your response.

              NinjaScript objects will remain in memory until the .NET garbage collection is ran and this cannot be forced other than restarting NinjaTrader. The behavior you detailed in both cases is expected.

              Please let me know if you have any questions.

              Comment


                #8
                Ah, I see. Not being a programmer per se, I now at least have an idea where the problems come from that I experienced. What you say by extension means that even if I only open a Daily chart with indicators in it to take a look at, and then close that chart again, it will remain in memory. And if I do that often enough perhaps with other instruments, the memory usage will keep increasing and increasing.

                So, it's better to stay with a certain chart set up and instrument(s) and then not change anything once worked out.

                Again thanks for the information.

                Thanks also to sledge for providing data for comparison.

                sandman

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by sidlercom80, 10-28-2023, 08:49 AM
                168 responses
                2,262 views
                0 likes
                Last Post sidlercom80  
                Started by Barry Milan, Yesterday, 10:35 PM
                3 responses
                10 views
                0 likes
                Last Post NinjaTrader_Manfred  
                Started by WeyldFalcon, 12-10-2020, 06:48 PM
                14 responses
                1,429 views
                0 likes
                Last Post Handclap0241  
                Started by DJ888, 04-16-2024, 06:09 PM
                2 responses
                9 views
                0 likes
                Last Post DJ888
                by DJ888
                 
                Started by jeronymite, 04-12-2024, 04:26 PM
                3 responses
                41 views
                0 likes
                Last Post jeronymite  
                Working...
                X