Take the 2-minute tour ×

I am trying to generate some data to use in a report. The issue is that the first time that I run my program with a data set, it takes longer to process the data. Then the rest of the times that I run the program with the data set it is quicker by about half the time. My problem is that I need to duplicate the results of the first run each time. Because in reality the user will never load the data set multiple times in a row. So my question is how can I make java stop caching these files across multiple runs. Or is it my Mac that is doing it for me. Also, the only other way for me to duplicate the first run results is to restart the machine, and I do not want to do that each time I want to run a test. Any ideas would be greatly appriciated.

share|improve this question
cannot understand a thing, please post your code –  mprabhat Jun 4 '12 at 16:50
Have you tried cycling through different data sets until the original has been evicted from the cache? –  TEOUltimus Jun 4 '12 at 17:16

1 Answer 1

Java's not caching the files, the operating system is.

I assume you're working on performance (or else why would you care?). You could create many copies of the data and load a different one each time.

share|improve this answer
I figured it was the operating system. It doesn't matter how many copies of the data I have. Once it sees the data it is cached and the speed up is still seen. So I guess the real question is how can I get rid of this cache. –  Strange Jun 4 '12 at 17:13
@Strange So you're saying that using a different but identical data set is still faster than the first run? That doesn't seem right. The OS doesn't know the data is identical until it is read off disk. Are you sure you're running your program with different files each time? –  Bryan Head Jun 4 '12 at 18:30

Your Answer


