Link to home
Start Free TrialLog in
Avatar of plq
plqFlag for United Kingdom of Great Britain and Northern Ireland

asked on

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
Avatar of CIGHN
CIGHN

Avatar of plq

ASKER

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
Avatar of jkr
Is there a particular reason why you want this to be slower?
Avatar of plq

ASKER

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
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.
Avatar of plq

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of plq

ASKER

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 !  
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of plq

ASKER

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.