How to flush the memory cache in SQL Server for testing

SQL-Server

SQL Server is of course caching data in order to minimize access to disks. Sometimes you want to clear that memory, for testing purposes for example. You can use DBCC commands in order to clear the system, proc, and session cache. See the SQL below:

 DBCC FREESYSTEMCACHE
 DBCC FREESESSIONCACHE
 DBCC FREEPROCCACHE