Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NTOrderStatus Function Memory

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

    NTOrderStatus Function Memory

    In the NTOrderStatus function there are these 2 lines:


    SetAllocReturnString(1); { alloc memory for returned string, TS will free that memory }
    SetMaxReturnStringLength(500); { limit the max length of return string to 500 }

    Since I am having a problem with a memory leak in TradeStation related to the use of this function, if I reduce the return strong length parameter, might this help? I assume the number is characters(bytes).

    #2
    Hello,

    Thanks for the post.

    This change would be untested or unsupported, it's unclear if this would help or what would be the best setting here for maximum efficiency without running into issue.

    If you do give this a run and test this the community would be interested in the results if you don't mind sharing.

    Thanks.

    Comment


      #3
      I have done some testing on reducing the return string length for the NTOrderStatus function. The function has been modified to the following:

      Code:
      { ** Copyright (c) 2005, NinjaTrader LLC [email protected] }
      DefineDLLFunc:  "NtDirect.dll", lpstr, "OrderStatus", lpstr;
      DefineDLLFunc:  "NtDirect.dll", int, "SetAllocReturnString", int;
      DefineDLLFunc:  "NtDirect.dll", int, "SetMaxReturnStringLength", int;
      
      inputs: OrderId(string);
      
      SetAllocReturnString(1);				{ alloc memory for returned string, TS will free that memory 	}
      SetMaxReturnStringLength(15);			{ limit the max length of return string to 15 					}
      
      NTOrderStatus15 = OrderStatus(OrderId);
      I called this function with the following ELD loaded on an @ES.D 3 minute chart with 12 months of data:

      Code:
      once begin
      	price = 1415 + round2fraction((random(1) - 0.5));
      	OrderID = numtostr(random(10000),0);
      	value1 = NTCommand("PLACE","Sim101","Buy",3,"Limit",price,0,"Day","",OrderID,"","");
      	end;
      	
      
      //value1 = NTChange(OrderID,0,price,0);	
      
      NTOS = NTOrderStatus15(OrderID);
      
      //NTFills = NTFilled(OrderID);
      This test was run while the market was closed. When I run the ELD using the 500 byte string length, each time a run it, the "Private Bytes" for Orchart reported by Process Explorer increases by about 18000 K. When I reduce the string length parameter to 15 as shown above, the increase drops to about 2000 K. The Private Bytes value will continue to increase with each subsequent run unless I disable all ELD's using NtDirect. Enabling the other functions such as NTFilled and NTChange has no effect on memory use. This week, I am going to test the reduced string length on live trading and I will let you know if there are any problems.

      Comment


        #4
        Atomic,

        This is an old post, but looks related to this discussion.



        Last edited by sledge; 08-26-2012, 10:53 AM. Reason: another thread

        Comment


          #5
          Thanks for pointing those out. I am not a programmer, but it seems to me that changing the length of the return string to something less than 500 does not violate the requirement of not changing the string length of an EasyLanguage variable. I am soon going to find out. In the case of the NTOrderStatus function, none of the return string lengths are more than 15 characters, so it is a little puzzling that this parameter would be set to 500, which would seem to guarantee unnecessary memory consumption when the return string alloc parameter is set to 1.

          Comment


            #6
            I am now running the NTOrderStatus function as follows and without problems.

            Code:
            SetAllocReturnString(1);				{ alloc memory for returned string, TS will free that memory 	}
            SetMaxReturnStringLength(15);			{ limit the max length of return string to 500 					}
            I left the comment at the original value as a reminder. I still have a couple of questions.

            Since the longest string returned by this function is something under 15, why would you ever use 500 or why was this value set at 500?

            What are the consequences of setting the "SetAllocReturnString" parameter to zero?

            Comment


              #7
              Thanks for letting us know.

              I would not change it unless you had a specific reason and tested that it specifically worked.

              This settings work for the majority of our clients on the TS Bridge.

              -Brett

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by traderqz, Today, 12:06 AM
              5 responses
              8 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Started by Mongo, Today, 11:05 AM
              2 responses
              7 views
              0 likes
              Last Post Mongo
              by Mongo
               
              Started by guillembm, Today, 11:25 AM
              0 responses
              3 views
              0 likes
              Last Post guillembm  
              Started by Tim-c, Today, 10:58 AM
              1 response
              3 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by traderqz, Yesterday, 09:06 AM
              4 responses
              27 views
              0 likes
              Last Post traderqz  
              Working...
              X