You won't get a true picture of memory usage from Task Manager if the account the service is running under has the lock pages in memory privilege (edit: as per Mark Rasmussen's comment/link). To determine how much memory is being used you can look at:
- SQLServer:Memory Manager\Total Server Memory perfmon counter
- DMVs
I can't recall if there is a DMV or combination of that will give you the total memory allocation but the following will show the bulk of it.
SELECT TOP(10) [type] AS [Memory Clerk Type], SUM(single_pages_kb) AS [SPA Mem, Kb]
FROM sys.dm_os_memory_clerks
GROUP BY [type]
ORDER BY SUM(single_pages_kb) DESC OPTION (RECOMPILE);
SELECT DB_NAME(database_id) AS [Database Name],
COUNT(*) * 8/1024.0 AS [Cached Size (MB)]
FROM sys.dm_os_buffer_descriptors
WHERE database_id > 4 -- system databases
AND database_id <> 32767 -- ResourceDB
GROUP BY DB_NAME(database_id)
ORDER BY [Cached Size (MB)] DESC OPTION (RECOMPILE);
The second is the most interesting usually, buffer pool allocations by database. This is where the lions share will be used and it can be useful to understand which of your databases are the biggest consumers.
There are other memory consumers outside of the buffer pool. For instance, SQL Server will use memory for worker threads, multi-page allocations, linked servers, extended stored procedures, CLR, etc.
The buffer pool is never going to equate to 100% of memory consumed by SQL Server. It's a common misconception, as well as setting max memory will be the actual max memory SQL Server uses (not true).
EDIT: Here's how I think you could get non-buffer pool memory size. Note: wait for the input of other SQL Server professionals before taking this query as fact. I cannot guarantee that it is absolutely correct.
declare
@data_cache_size_mb decimal(12, 2),
@plan_cache_size_mb decimal(12, 2),
@total_mem_mb decimal(12, 2)
select
@data_cache_size_mb = count(*) * 8 / 1024.
from sys.dm_os_buffer_descriptors
select
@plan_cache_size_mb = sum(size_in_bytes) / 1024. / 1024.
from sys.dm_exec_cached_plans
select
@total_mem_mb = sum(pages_allocated_count) * 8 / 1024.
from sys.dm_os_memory_objects
select
@data_cache_size_mb as data_cache_size_mb,
@plan_cache_size_mb as plan_cache_size_mb,
@data_cache_size_mb + @plan_cache_size_mb as buffer_pool_size_mb,
@total_mem_mb as total_instance_mem_mb,
@total_mem_mb - (@data_cache_size_mb + @plan_cache_size_mb) as non_buffer_pool_size_mb
Best Answer
SQL Server is supposed to use all the memory. If you want to reserve memory for other things set the max server memory setting in SQL Server so that it'll stop eating up all the memory.