Go Back   NinjaTrader Support Forum > NinjaTrader 8 > Indicator Development

Indicator Development Support for the development of custom indicators using NinjaScript.

NinjaTrader
Reply
 
Thread Tools Display Modes
Old 03-20-2017, 04:02 PM   #1
reach4thelasers
Senior Member
 
Join Date: Aug 2015
Location: London, United Kingdom
Posts: 260
Thanks: 26
Thanked 29 times in 25 posts
Default 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 Images
File Type: png series.PNG (92.3 KB, 6 views)
reach4thelasers is offline  
Reply With Quote
Old 03-22-2017, 08:51 AM   #2
NinjaTrader_Jesse
NinjaTrader Customer Service
 
NinjaTrader_Jesse's Avatar
 
Join Date: Mar 2014
Location: Denver, CO
Posts: 3,411
Thanks: 28
Thanked 890 times in 830 posts
Default

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?

http://ninjatrader.com/support/helpG...lightsub=Reset

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.
NinjaTrader_Jesse is offline  
Reply With Quote
Old 03-22-2017, 11:35 AM   #3
reach4thelasers
Senior Member
 
Join Date: Aug 2015
Location: London, United Kingdom
Posts: 260
Thanks: 26
Thanked 29 times in 25 posts
Default

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
reach4thelasers is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Series<T> Termination Question aslane Version 8 Beta 1 11-02-2016 10:18 AM
Series<T> with custom Object mk77ch Indicator Development 2 10-20-2016 08:36 AM
Series<T> implementing IEnumerable gregid Version 8 Beta 4 10-30-2015 12:09 PM
How/When do you pass PriceSeries<double>, ISeries<double> or Series<double>, DaFish Version 8 Beta 10 08-14-2015 01:56 PM
Series<T> issue cls71 Version 8 Beta 3 06-02-2015 07:08 AM


All times are GMT -6. The time now is 02:03 AM.

Futures, foreign currency and options trading contains substantial risk and is not for every investor. An investor could potentially lose all or more than the initial investment. Risk capital is money that can be lost without jeopardizing ones financial security or lifestyle. Only risk capital should be used for trading and only those with sufficient risk capital should consider trading. Past performance is not necessarily indicative of future results. View Full Risk Disclosure.

CFTC Rules 4.41 - Hypothetical or Simulated performance results have certain limitations, unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not been executed, the results may have under-or-over compensated for the impact, if any, of certain market factors, such as lack of liquidity. Simulated trading programs in general are also subject to the fact that they are designed with the benefit of hindsight. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown.

This website is hosted and operated by NinjaTrader, LLC (“NT”), a software development company which owns and supports all proprietary technology relating to and including the NinjaTrader trading platform. NT is an affiliated company to NinjaTrader Brokerage (“NTB”), which is a NFA registered introducing broker (NFA #0339976) providing brokerage services to traders of futures and foreign exchange products. This website is intended for educational and informational purposes only and should not be viewed as a solicitation or recommendation of any product, service or trading strategy. No offer or solicitation to buy or sell securities, securities derivative or futures products of any kind, or any type of trading or investment advice, recommendation or strategy, is made, given, or in any manner endorsed by any NT affiliate and the information made available on this Web site is not an offer or solicitation of any kind. Specific questions related to a brokerage account should be sent to your broker directly. The content and opinions expressed on this website are those of the authors and do not necessarily reflect the official policy or position of NT or any of its affiliates. 

Vendors along with their websites, products and services, collectively referred to as (“Vendor Content”), are independent persons or companies that are in no manner affiliated with NT or any if its affiliates. NT or any of its affiliates are not responsible for, do not approve, recommend or endorse any Vendor Content referenced on this website and it’s your sole responsibility to evaluate Vendor Content. Please be aware that any performance information provided by a vendor should be considered hypothetical and must contain the disclosures required by NFA Rule 2-29(c). If you are interested in learning more about, or investigating the quality of, any such Vendor Content you must contact the vendor, provider or seller of such Vendor Content. No person employed by, or associated with, NT or any of its affiliates is authorized to provide any information about any such Vendor Content. Visit the CFTC resources for education regarding the industry and signs of fraud.