Is plan cache included in Buffer Pool?

Alessandro 2016-12-15 12:43:27

Hello community,
I'm facing with a question that drives me crazy: I try to figure out if plan cache (like other memory areas) are included in buffer pool.
I consider the output of sys.dm_os_memory_clerks, where MEMORYCLERK_SQLBUFFERPOOL, MEMORYCLERK_SQLCONNECTIONPOOL, CACHESTORE_SQLCP seem to be distinct memory areas. From that I understand that plan cache (CACHESTORE_SQLCP + CACHESTORE_OBJCP + CACHESTORE_PHDR + CACHESTORE_XPROC) is not included in MEMORYCLERK_SQLBUFFERPOOL because they are different clerk types. Moreover, I run DBCC FREEPROCCACHE, and I noticed that MEMORYCLERK_SQLBUFFERPOOL clerk memory is not changed at all, while the above mentioned CACHESTORE_SQLCP,CACHESTORE_OBJCP,CACHESTORE_PHDR, CACHESTORE_XPROC become ZERO.
So, I suppose that plan cache is not include, but I read that some authors say the opposite. Which is the correct answer?
Thanks a lot Alessandro
Aaron Bertrand 2017-01-08 16:51:18
I think the main problem is that some people call all of SQL Server's usable memory the "buffer pool" – usually what they really mean by this is the memory that contains the buffer pool, the plan cache, and other memory allocations. They are indeed separate, but they do affect each other (see this article).