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 thanajo, 05-04-2021, 02:11 AM
      4 responses
      470 views
      0 likes
      Last Post tradingnasdaqprueba  
      Started by aa731, Today, 02:54 AM
      0 responses
      4 views
      0 likes
      Last Post aa731
      by aa731
       
      Started by Christopher_R, Today, 12:29 AM
      0 responses
      10 views
      0 likes
      Last Post Christopher_R  
      Started by sidlercom80, 10-28-2023, 08:49 AM
      166 responses
      2,237 views
      0 likes
      Last Post sidlercom80  
      Started by thread, Yesterday, 11:58 PM
      0 responses
      6 views
      0 likes
      Last Post thread
      by thread
       
      Working...
      X