Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Memory

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

    Memory

    Hi,

    I'm currently developing a strategy on NT7.14. In general everything is running well (apart from that annoying "Enable" bool that needs to be set when-ever I want to re-run it). My problem appears when I attempt to shut down NT and find the GUI disappears but the process is still alive and well in memory. I run it with IB TWS and wander if something is not being released.

    I need to back test large amounts of data and have loaded 60 days of 2 minute bars. I have done some very basic systems tests that appear to show Ninja is growing in size but never shrinking (classic sign of memory leakage). I have loaded several charts one after the other loading various FX currencies with variations in the number of bars loaded. In all cases I see the Ninja process grow but it never returns to the sweat little process it starts as. Eventually after a hard days development, I see the Ninja process bloats out to 450M. Also, when I try to cycle it, Ninja puts it's hands on its hips and refuses to budge. After a reasonable period, I am forced to hit it on the head by killing the process.

    Regards,
    Paul

    #2
    Hi Paul, thanks for the report - so far I've not seen a scenario like this...are you testing with latest beta 14 and TWS 900.6? It might be helpful to also test with a fresh .NET framework install including the service packs offered via Windows Update.

    Comment


      #3
      Hi Bertrand,

      I already have the latest version of everything.

      Paul

      Comment


        #4
        Paul, are you using any custom resources in the strategies then? Do you release them via OnTermination()?

        Comment


          #5
          Hi,

          I use 2 indicators, an Abstract strategy and a derived strategy.

          There are no externals used.

          Do I need to release these resources even after the charts they are created on are destroyed? Isn't this handled by the built in Garbage collector in .Net?

          No I don't release them using OnTermination, is this necessary?

          Regards,

          Paul

          Comment


            #6
            Paul, I'm not sure exactly what you mean by Abstract and Derived strategies, but if you stay within the NinjaScript methods you should not have to self terminate / dispose. Is there any way I can test this to my end to reproduce? Then please contact me at support at ninjatrader dot com Attn Bertrand.

            Thanks

            Comment


              #7
              Originally posted by NinjaTrader_Bertrand View Post
              Paul, I'm not sure exactly what you mean by Abstract and Derived strategies,
              I have created an abstract class that inherits from Strategy and then I've created a derived class that inherits from my abstract class.

              This is a standard Object Oriented feature of the C# language and is designed to create a management layer that can be re-used by several derived strategies.

              but if you stay within the NinjaScript methods you should not have to self terminate / dispose.
              I don't believe I have strayed from the Ninjascript path. Also, why do I need to kill the Ninjatrader.exe process? There is nothing I can do to cause this kind of issue?
              Is there any way I can test this to my end to reproduce? Then please contact me at support at ninjatrader dot com Attn Bertrand.
              Thanks
              We have put a lot of work into both the design and testing of our strategy and would prefer to keep our code confidential.

              The strategy uses 2 indicators and lots of uniquely tagged chart text indicators. I did this as during a test, unless the tags are unique (you must be using a Hash table), early text markers disappear.

              We are doing lots of regressive testing on the same data set (90 days of 2min bars) using the Enable and Disable parameter. How are all those tagged text items dealt with in your chart class?

              BTW there should be a separate button on the screen some place as testing is fundamental to development and having to toggle that attribute all the time to re-run tests is a little silly and wastes development time. Why not put a click button that once that flag is set to enable, you can test and test by clicking the TEST button.

              The indicators are created and initialised once in the Initialise() routine then used throughout the entire strategy.

              I hope this helps.

              Regards,

              Paul

              Comment


                #8
                pbcah,

                Unfortunately we are unable to provide you support for this level of C# programming. Our support can only cover the methods and properties of NinjaScript. When you are working with more advanced C# programming techniques we are unfortunately unable to extend our support out there. You could consider some of the 3rd party NinjaScript Consultants who may be able to assist with such programming.

                To retest things I believe you can just press F5 to reload the NinjaScript. If you actually made changes to parameters and things like that you may require a new instance of your strategy to test those though.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  Actually pressing F5 to 'reload the ninjascript' can be a cause of memory issues if you have a large number of indicators installed.

                  The reason is due to .NET framework limitations a dynamic assembly cannot be unloaded from an appdomain once it is loaded. Every time you recompile with F5 NT creates a new dynamic assembly which eats up some amount of memory (ie all the old dynamic assemblies are still in memory and cannot be unloaded, so your memory usage will only go up and up and never down)

                  You can mitigate this problem by keeping the number of indicators installed to a minimum. I used to have hundreds of indicators installed and every time I would recompile with F5 it would lose 1.6MB.. now I have a very limited set of indicators and it only takes up 20kB.

                  Comment


                    #10
                    Your findings are accurate. Unfortunately there is no way to "unload" an assembly which no longer is used in .NET (unless you work with AppDomains which come with a serious performance penalty). This is a limitation of the .NET concept.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                    0 responses
                    596 views
                    0 likes
                    Last Post Geovanny Suaza  
                    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                    0 responses
                    343 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by Mindset, 02-09-2026, 11:44 AM
                    0 responses
                    103 views
                    0 likes
                    Last Post Mindset
                    by Mindset
                     
                    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                    0 responses
                    556 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by RFrosty, 01-28-2026, 06:49 PM
                    0 responses
                    554 views
                    1 like
                    Last Post RFrosty
                    by RFrosty
                     
                    Working...
                    X