- Running a fresh instance of 64-bit NinjaTrader for each test
- Market Analyzer has 4 columns: Description, Instrument, SMA(1), and the indicator being tested. The first three have little effect on performance.
- Market Analyzer has 1600 rows
- Data is daily
- Market Analyzer | Properties | # of bars to look back = 512
- Indicator setting in "Columns" dialog: # of bars to look back = 512
- Indicator setting in "Columns" dialog: Maximum bars look back = 256
- I ran tests with regression periods of 252, 126, and 63
I reduced OnBarUpdate() to the following -- I do not know how to make the code much simpler:
protected override void OnBarUpdate()
{
if (CurrentBar<2) return;
//IndicatorLine.Set(LinRegSlope(Math.Min(CurrentBar,period1Bars))[0]);
//IndicatorLine.Set(50);
return;
}
- The run took 0:15 (15 seconds) and the working set grew to 0.7GB
Next I reversed the commenting for the remaining tests, making the linear regression call operational. Here are the results of three runs, restarting NinjaTrader between runs:
- Period=252 time=5:29 working set=10.3GB
- Period=126 time=1:59 working set=5.6GB
- Period=63 time=1:02 working set=3.1GB
-- There would have been the same number of calls to linear regression in all tests -- what varied was the length of the linear regression being calculated. The longer the linear regression, the more memory got consumed.
-- In each case, the working set started out small, and increased steadily as the code ran. In other words, memory was being consumed as the code executed. My code is not allocating any memory as it executes -- so it must be the library code. It looks as if each call to LinRegSlope() consumes an amount of memory that varies with the length of the regression.
In case anyone is wondering, the machine is an i7 quad core 3.4GHz with 16GB RAM, running Windows 8.1, so I doubt that the machine itself is causing problems. For example, the tests never got into paging.
OK -- how should I do the task at hand without growing to such a ridiculous working set,?
--EV


Comment