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

Clearing Series<T>

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

    Clearing Series<T>

    I've got a 20Gb Memory Leak situ going down here

    I've tracked it down to my use of the Series<T> Generic, to store rich objects which are make up a huge object graph shared between multiple Ninjascript contexts.

    That's fine, I just need to get the remove all the contents from the Series<T> instances on termination, and dispose the objects if applicable. Easy.

    Not easy lol.

    the Count() method gives a value of 1000 even though there's only a few objects in there, I don't know how many objects there are or at which position they are at.

    This code doesn't work, because IsValidDataPoint returns true, despite the assignment to null failing as an ArrrayIndexerOutOfBounds exception.


    Code:
    	for (int i = 1; i <= _validPivots.Count; i++)
    	{
    		if (_validPivots.IsValidDataPointAt(i))
    		{
    			var disposable = _validPivots.GetValueAt(i) as IDisposable;
    					
    			if (disposable != null) disposable.Dispose();
    			_validPivots[i - 1] = null;
    		}
    }
    I've attached a screenshot of the Debug Session. Showing the Public Count Property showing 500, but the internal structures showing 2 items. IsValidDataPoint(i) passed as true. But the assignment failed on indexer[i].

    Am I missing something obvious here? Or is it impossible to clear a Series?
    Attached Files

    #2
    Hello,

    Thank you for the post.
    I wasnt able to tell from what you have provided, have you tried using Reset() in your dispose logic that you have shown?



    Reset would reset the internal marker for IsValidDataPoint, if you are disposing of the object and then set the IsValidDataPoint to not valid it could be ignored from your logic and eventually garbage collected.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hey Jesse, thanks for the response. I did see the docs for Reset but didn't think it was related. I will give it a try and get back to you!

      Thanks

      Kevin

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by merzo, 06-25-2023, 02:19 AM
      10 responses
      823 views
      1 like
      Last Post NinjaTrader_ChristopherJ  
      Started by frankthearm, Today, 09:08 AM
      5 responses
      15 views
      0 likes
      Last Post NinjaTrader_Clayton  
      Started by jeronymite, 04-12-2024, 04:26 PM
      3 responses
      43 views
      0 likes
      Last Post jeronymite  
      Started by yertle, Today, 08:38 AM
      5 responses
      16 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Started by adeelshahzad, Today, 03:54 AM
      3 responses
      20 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Working...
      X