[Blotter-commits] r1108 - pkg/quantstrat/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Jul 24 16:21:44 CEST 2012


Author: opentrades
Date: 2012-07-24 16:21:44 +0200 (Tue, 24 Jul 2012)
New Revision: 1108

Modified:
   pkg/quantstrat/R/parameters.R
Log:
fixed accumulating memory bug in .blotter environment by cleaning .blotter at start of each 
foreach loop in applyParameters() 



Modified: pkg/quantstrat/R/parameters.R
===================================================================
--- pkg/quantstrat/R/parameters.R	2012-07-19 20:34:47 UTC (rev 1107)
+++ pkg/quantstrat/R/parameters.R	2012-07-24 14:21:44 UTC (rev 1108)
@@ -478,12 +478,19 @@
 	testPackListPRL<-foreach (i = 1:psize, .export=c('instruments',symbols,'getSymbols','blotter','tmp_strategy'),.verbose=TRUE,...=...) %dopar% 
 			
 			{
+				if(verbose) print(paste('===> now starting parameter test', i))
+
 				require(quantstrat, quietly=TRUE)
 				
+				# loops must be run with an empty .blotter environment each, or .blotter appears to accumulate portfolios and accounts
+				# and passes them from one loop to the next on each CPU - JH July 2012
+				rm(list=ls(pos=.blotter), pos=.blotter)
+				gc(verbose=verbose)
+
 				testPack<-list()
 				
 				#Pass environments needed.
-                loadInstruments(instruments)
+				loadInstruments(instruments)
 				.getSymbols<-as.environment(getSymbols)
 				
 				#Unpack symbols to worker. change later.
@@ -649,6 +656,7 @@
 				return(testPack)
 				
 			}	# Loop i
+			gc(verbose=verbose)
 	
 	
 	for (k in 1: nrow(paramTable)){



More information about the Blotter-commits mailing list