Here's what I found on the web:
When you query a large amount of data, sqlserver caches the query results in memory to make sure you get the results quickly the next time you query for the same record, so the memory usage spikes.
After you finish this query, sqlserver will not release the memory right away, the data will still be put in the memory, this is the optimization strategy of sqlserver, sqlserver will keep occupying your system memory to speed up the operation of sqlserver, it will automatically release part of the memory only when the other services in your system also need memory. memory. Bottom line, sqlserver will not let your system have unused memory unless you set the maximum memory usage of sqlserver. There is nothing wrong with this, if you have a large system, give sqlserver a separate machine, this will improve its performance.
If you're just using it for development, to get sqlserver to free up memory, just restart the sqlserver service. If you don't want sqlserver to take up too much memory, set the maximum memory usage for sqlserver.
Setting the max memory works a lot better!