I think I have a basic question here that many might have encountered. When I run a query in SQL Server it will load in memory all the data it needs for query execution (for example, if there is a join then it would load the necessary data from those two tables) but when the query finishes executing the memory consumed by SQL Server is not released.
I noticed this because a few days back I was analyzing a query that takes up a lot of tempdb space. When I used to run the query it would (by the end of execution) consume upto 25 GB of RAM. This 25 GB RAM would not be released unless I restarted the MSSQLSERVER service.
How do you guys do SQL Server memory management? This is clearly an issue right?
I would also like to hear if you do something specific to clear the memory used up by a single query.
Thanks in advance!