Hello, we are using SQL Server 2012:
--Microsoft SQL Server 2012 - 11.0.2100.60 (X64)
--Enterprise Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1)
and our server over the past few weeks has seen the optimizer memory grow from only a few tens of MB to 20GB, 30GB, 40GB, and beyond. It is completely hogging the memory on the server. Our page life expectancy has decreased significantly since more than half of the 60GB of memory available is going to the optimizer. There seems to be no way to stop the optimizer memory from increasing. Our workload is pretty ad hoc, so I enabled optimize for ad hoc workloads, but this did not slow it down. We tested clearing the caches, but it appears optimizer memory is not the plan cache, so clearing them did not help, in fact it may have made it worse since it freed up even more memory for the optimizer to consume. On our healthy servers, this memory is usually less than 1 GB so having it grow to 40GB and higher is surprising to me.
Here's some relevant stats:
total memory for the server is 60GB with 4GB left for the OS. This instance is the only instance of SQL Server and the only software running on the server. No anti-virus is running on it. The flag for process_physical_memory_low is 1, process_virtual_memory_low is 0. The server memory status is "Available physical memory is high". All 60GB are being used. PLE (page life expectancy) ranges from 0 to a few hundred to a thousand, but we are used to 10s or even 100s of thousands. We also collect stats on page reads or hard-faults by taking two snapshots and taking the difference since the counters are cumulative. So page reads /sec is oddly 0 in the past few hours, but I can see as PLE goes down to 0-10, page reads /sec goes way up. Our stolen memory counter is positively correlated with the optimizer memory --- with stolen memory reaching 50GB when the optimizer memory is at 47GB, currently. I can see latch waits /sec is much higher than normal and lots of IO wait stats, probably b/c the disks are being used much more than normal since most memory is going to the optimizer.
Any ideas as to why the optimizer would behave like this in SQL Server 2012? Restarting the server will return us to a low optimizer memory and allow data caching as usual, but I am more interested in possible causes of this behavior as I would expect it to come back over a few weeks anyway after a restart. Thanks much!