FIX: Cursor Plans Are Not Removed From the Cache When Virtual Memory Depleted (818095)



The information in this article applies to:

  • Microsoft SQL Server 2000 Developer Edition
  • Microsoft SQL Server 2000 Standard Edition
  • Microsoft SQL Server 2000 Enterprise Edition
  • Microsoft SQL Server 2000 Personal Edition
  • Microsoft SQL Server 2000 Enterprise Evaluation Edition
  • Microsoft SQL Server 2000 Workgroup Edition
  • Microsoft SQL Server 2000 Desktop Engine (MSDE)
  • Microsoft SQL Server 2000 Developer Edition 64 bit
  • Microsoft SQL Server 2000 Enterprise Edition 64-bit

SHILOH_BUGS:469116

SYMPTOMS

SQL Server may run slowly, and the SQL Server error log contains error messages that repeat continuously (as frequently as several times per second). The error messages are similar to:

2003-01-31 16:04:20.25 spid73 WARNING: Failed to reserve contiguous memory of Size= 65536.
2003-01-31 16:04:20.28 spid73 Buffer Distribution: Stolen=51347 Free=232 Procedures=14956 Inram=0 Dirty=4468 Kept=0 I/O=0, Latched=96, Other=98278 2003-01-31
16:04:20.28 spid73 Buffer Counts: Commited=169377 Target=169377 Hashed=102842 InternalReservation=261 ExternalReservation=0 Min Free=128
2003-01-31 16:04:20.28 spid73 Procedure Cache: TotalProcs=7374 TotalPages=14956 InUsePages=5589
2003-01-31 16:04:20.28 spid73 Dynamic Memory Manager: Stolen=66303 OS Reserved=38352 OS Committed=38324 OS In Use=35653 Query Plan=99539 Optimizer=0 General=1988 Utilities=168 Connection=183
2003-01-31 16:04:20.30 spid73 Global Memory Objects: Resource=1457 Locks=54 SQLCache=239 Replication=2
2:44 PM 2/3/2003LockBytes=2 ServerGlobal=44 Xact=19 2003-01-31 16:04:20.30 spid73 Query Memory Manager: Grants=0 Waiting=0 Maximum=84354 Available=84354

Note that in this particular message that the values for "OS Reserved", "OS Committed" and "OS In Use" are all greater than 30000. This value is specified in 8 KB blocks, so the numbers indicate that SQL Server has allocated almost 300 MB of memory in addition to what is allocated for the buffer pool (the memory sizevalue of the sp_configure stored procedure).

RESOLUTION

Service pack information

To resolve this problem, obtain the latest service pack for Microsoft SQL Server 2000. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:

290211 How to obtain the latest SQL Server 2000 service pack

Hotfix information

The English version of this fix has the file attributes (or later) that are listed in the following table. The dates and times for these files are listed in coordinated universal time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time tool in Control Panel.
   Date         Time   Version         Size             File name
   ----------------------------------------------------------------------------
   26-Feb-2003  03:41  2000.80.777.0      29,244 bytes  Dbmslpcn.dll     
   08-Feb-2003  05:43                    786,432 bytes  Distmdl.ldf
   08-Feb-2003  05:43                  2,359,296 bytes  Distmdl.mdf
   30-Jan-2003  01:55                        180 bytes  Drop_repl_hotfix.sql
   01-Feb-2003  00:32  2000.80.763.0   1,557,052 bytes  Dtsui.dll        
   30-Jan-2003  05:18                    746,470 bytes  Instdist.sql
   30-Jan-2003  01:55                      1,402 bytes  Inst_repl_hotfix.sql
   08-Feb-2003  06:40  2000.80.765.0      90,692 bytes  Msgprox.dll      
   01-Apr-2003  02:07                      1,873 bytes  Odsole.sql
   05-Apr-2003  01:46  2000.80.800.0      62,024 bytes  Odsole70.dll     
   02-Apr-2003  21:48  2000.80.796.0      57,904 bytes  Osql.exe         
   02-Apr-2003  23:15  2000.80.797.0     279,104 bytes  Pfutil80.dll     
   04-Apr-2003  21:27                  1,083,467 bytes  Replmerg.sql
   04-Apr-2003  21:53  2000.80.798.0     221,768 bytes  Replprov.dll     
   08-Feb-2003  06:40  2000.80.765.0     307,784 bytes  Replrec.dll      
   01-Apr-2003  02:23                  1,084,828 bytes  Replsys.sql
   03-Apr-2003  18:14                    104,868 bytes  Sp3_serv_uni.sql
   19-Mar-2003  18:20  2000.80.789.0      28,672 bytes  Sqlevn70.rll
   28-Feb-2003  01:34  2000.80.778.0     176,696 bytes  Sqlmap70.dll     
   08-Feb-2003  06:40  2000.80.765.0      57,920 bytes  Sqlrepss.dll     
   05-Apr-2003  01:47  2000.80.800.0   7,540,817 bytes  Sqlservr.exe     
   08-Feb-2003  06:40  2000.80.765.0      45,644 bytes  Sqlvdi.dll       
   26-Feb-2003  03:41  2000.80.777.0      29,244 bytes  Ssmslpcn.dll     
   26-Feb-2003  03:41  2000.80.777.0      82,492 bytes  Ssnetlib.dll     
   17-Mar-2003  14:49                    727,132 bytes  Sysmessages.sym
   28-Feb-2003  01:34  2000.80.778.0      98,872 bytes  Xpweb70.dll      
				
Note Because of file dependencies, the most recent hotfix or feature that contains the files may also contain additional files.


STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.This problem was first corrected in Microsoft SQL Server 2000 Service Pack 4.
SQL Server tries to use memory from the buffer pool for most internal allocations, but requests greater than 8 KB are routed to the normal operating system allocators. By default, SQL Server leaves a limited amount of address space for these types of allocations and also for things such as thread stack space, COM objects, extended stored procedures, and so on. You can modify the size of this region by using the -g command line parameter. For more information about the -g parameter, see SQL Server Books Online.

When SQL Server tries to allocate virtual memory for one of these large allocations, and that operation fails, it will try to remove cached query plans in hopes of freeing some of this memory. Before SQL Server 2000 Service Pack 3 (SP3), this operation would remove all query plans from cache, even if they were not using any of this memory. SQL Server 2000 SP3 introduced a change whereby only query plans that are known to be using this memory are removed from cache. This change introduced a problem where some query plans for cursors were not being removed.

Even with this fix, you might see the error message occasionally. Over time (minutes to hours) there may be additional cached plans that build up and the message occurs again. This can be normal and by itself should not be taken as a sign of a problem.

Modification Type:MinorLast Reviewed:9/27/2005
Keywords:kbHotfixServer kbQFE kbQFE kbfix kbbug kbSQLServ2000preSP4fix KB818095