• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 328
  • Last Modified:

Windows - How to drop the HDD cache

I'm writing a program which scans the HDD with a recursive FindFirstFile etc. Works great but the first time I run it after reboot, it takes about 75 seconds, the second time about 3 seconds and subsequently.

Clearly the info is getting cached either in the HDD memory or in Windows cache.

Is there any way of clearing this so I can replicate the slowness of the first time run, without the need to reboot ?

Programming or any other solution would be fine.

thanks
0
plq
Asked:
plq
2 Solutions
 
plqAuthor Commented:
Thanks, I can see some caching info in that link, but this relates to CreateFile and not FindFirstFile, there is no option to specify these flags in FindFirstFile ?

Please let me know what you had in mind.

thanks again
0
 
jkrCommented:
Is there a particular reason why you want this to be slower?
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
plqAuthor Commented:
Yes, the software will normally run one time on the end clients, sometimes as part of bootup, but usually from a sysadmin's scheduled task. So I have to optimise it for uncached behaviour. To do the optimisation, I need to be able to reproduce the same conditions as just after a reboot. But a reboot of a box takes quite some time, so I'm hoping for a solution like a dos command which clears any cache, or a way of calling findfirstfile that stops it caching in the first place.

Just to clarify this is purely for my debug environment so I can replicate the slowness of running the software against a booted up machine.

thanks
0
 
jkrCommented:
OK, this is just an idea, though it could work: Create a network share for your partition and access it via '\\machine\sharename' - this might circumvent the cache.
0
 
plqAuthor Commented:
Thanks, but in this case it would take quite a bit of development effort to do that.

I guess no might be a valid answer here, but lets just see what other ideas come in.. thanks
0
 
jkrCommented:
>>in this case it would take quite a bit of development effort to do that.

I hope not. It mainly would boil down to

net share add Testing=c:\
net use x: \\.\Testing

and use 'x:' as your root directory.
0
 
plqAuthor Commented:
The program isn't just a root scan of all folders, it scans for specific folders via the registry, shortcuts, key areas, etcm and then deep scans those to specific levels depending on context. So there's not a single root. I'll see if I can fudge a way around it, but I suspect I need some "cache killer" program that fools the OS and disks into losing any cache !  
0
 
LMiller7Commented:
The system cache in Windows is controlled by registry entries which are not well documented. One program that claims to be able to control the cache is Cacheman:
http://cacheman.outertech.com/index.php?_charisma_page=product&id=2

I have not used this program so I don't know anything more than is on the website. I cannot verify it's claims and merely suggest it as a possibility.

Note that I normally do not recommend programs of this type as they usually do more harm than good. But it may do what you want.

0
 
plqAuthor Commented:
I never found a solution, so ended up spending days rebooting it instead. THe shares stuff still got cached

thanks for helping anyway. I guess it just might not be possible to remove cached information.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now