Hello Andres, thanks for answer.
My original code has 2 loops inside. The first one stablish the factor combination and the second one runs a bootstrap of 1000 repetition for each combination. The thing is that the program runs really fast at start, but in every combination is getting slowlier. For example, the first combination runs up to 50 simulation/second, but the process continues is slowing down little by little up to 1 simulation/second o less. The complete process has about 1,5million simulations, so you can imagin the time that it takes to finish it.
If I stop the process at any time, clean the memory ("rm(list=ls()") and run it again, R has the same speed of process that before, but if I close completely the program and restart from 0, R recoveries the highest speed. Probably, program saturates by save any kind of information, but I have made sure that the vectors in which I save the results are reset on each loop.
That is why I need to separate the bootstrap of 1000 simulation from the fisrt loop. That is to say, in each factor combination call to another session of R, run the bootstrap for that combination, take the results and close it. In this way the program is restarted and whatever is saturating the program is released for each combination.
I think source(mysecondscript.R) is running in the same R session as original code, so the problem persists.
Any idea?, Sorry if I explain me bad.
Thank you.