When a SQL Server 2005 instance (SP3 Standard Edition) configured with 3.3GB physical RAM starts throwing Event ID 701 errors during routine operations like transaction log backups, we're looking at a complex memory allocation issue. This becomes particularly challenging in multi-role servers handling database, application, and web services simultaneously.
-- Current memory settings check
SELECT
physical_memory_in_bytes/1048576.0 AS [Physical Memory (MB)],
virtual_memory_in_bytes/1048576.0 AS [Virtual Memory (MB)],
bpool_committed*8/1024.0 AS [SQL Committed Memory (MB)],
bpool_commit_target*8/1024.0 AS [SQL Target Memory (MB)]
FROM sys.dm_os_sys_info;
-- Current sp_configure values
EXEC sp_configure 'show advanced options', 1;
RECONFIGURE;
EXEC sp_configure 'min server memory';
EXEC sp_configure 'max server memory';
EXEC sp_configure 'awe enabled';
The presence of multiple linked servers (SQL Server 2000/2005, Oracle 10g, OSI PI) introduces additional memory overhead that SQL Server's buffer pool must accommodate. Each distributed query consumes memory resources that count toward the 2000MB cap you've set.
1. Immediate Memory Relief:
-- Temporary workaround to release memory pressure
DBCC FREESYSTEMCACHE('ALL');
DBCC FREESESSIONCACHE;
DBCC FREEPROCCACHE;
2. Configure Memory More Effectively:
-- Recommended settings for your 3.3GB system
EXEC sp_configure 'min server memory', 1024; -- Set minimum to 1GB
EXEC sp_configure 'max server memory', 2500; -- Allow some OS overhead
RECONFIGURE;
-- For AWE configuration (if needed)
EXEC sp_configure 'awe enabled', 1;
RECONFIGURE;
-- Create a baseline memory usage log
CREATE TABLE #MemoryUsage (
sample_time DATETIME,
available_physical_memory INT,
available_virtual_memory INT,
sql_physical_memory_in_use INT
);
INSERT INTO #MemoryUsage
SELECT
GETDATE(),
available_physical_memory_kb/1024,
available_virtual_memory_kb/1024,
physical_memory_in_use_kb/1024
FROM sys.dm_os_process_memory;
-- Schedule this to run every 15 minutes via SQL Agent
For distributed queries that might be consuming excessive memory:
-- Example of memory-efficient linked server query
SELECT column1, column2
FROM OPENQUERY(ORACLE_LINKED_SERVER,
'SELECT ONLY_REQUIRED_COLUMNS FROM LARGE_TABLE WHERE DATE_COL = ''20230101''')
OPTION (MAXDOP 1, OPTIMIZE FOR UNKNOWN);
Since the error occurs during log backups, consider splitting the backup jobs:
-- Staggered backup script example
DECLARE @dbname NVARCHAR(128);
DECLARE db_cursor CURSOR FOR
SELECT name FROM sys.databases WHERE recovery_model_desc = 'FULL';
OPEN db_cursor;
FETCH NEXT FROM db_cursor INTO @dbname;
WHILE @@FETCH_STATUS = 0
BEGIN
EXEC('BACKUP LOG [' + @dbname + '] TO DISK = ''E:\Backups\' + @dbname + '_' +
REPLACE(CONVERT(VARCHAR(20), GETDATE(), 112), '/', '') + '.trn''');
WAITFOR DELAY '00:05:00'; -- 5 minute delay between backups
FETCH NEXT FROM db_cursor INTO @dbname;
END
CLOSE db_cursor;
DEALLOCATE db_cursor;
- Separate application/web services to dedicated servers
- Upgrade to newer SQL Server version with better memory management
- Consider increasing physical RAM beyond 4GB (requires 64-bit OS)
- Implement Resource Governor to prioritize critical operations
When SQL Server 2005 throws Event ID 701 ("There is insufficient system memory to run this query"), we need to examine multiple configuration aspects. A common misconception is that this error only relates to query execution, but as we've seen, it can occur during backup operations - particularly when dealing with complex environments involving linked servers.
-- Check current memory configuration
EXEC sp_configure 'show advanced options', 1;
RECONFIGURE;
EXEC sp_configure 'max server memory';
EXEC sp_configure 'min server memory';
EXEC sp_configure 'awe enabled';
Linked servers can silently consume memory outside SQL Server's memory management. Each connection maintains its own memory pool, and with heterogeneous systems like Oracle 10g and OSI PI, memory usage becomes unpredictable.
-- Identify active linked server connections
SELECT s.session_id, s.login_name, s.host_name,
s.program_name, s.status, s.cpu_time,
s.memory_usage, s.reads, s.writes
FROM sys.dm_exec_sessions s
WHERE s.is_user_process = 1
AND EXISTS (
SELECT 1 FROM sys.dm_exec_connections c
WHERE c.session_id = s.session_id
AND c.net_transport = 'TCP'
);
Transaction log backups in memory-constrained environments require special consideration. The backup operation needs working memory to process the log chain, especially when:
- Multiple databases have concurrent backup jobs
- Transaction logs are large and fragmented
- Other memory-intensive operations run simultaneously
For a server with 3.3GB physical memory (as reported by sysinfo), these settings may help stabilize operations:
-- Recommended settings for 3.3GB physical memory system
EXEC sp_configure 'max server memory', 2400; -- Leave 900MB for OS and apps
EXEC sp_configure 'min server memory', 512; -- Prevent sudden starvation
EXEC sp_configure 'awe enabled', 1; -- If Enterprise Edition
RECONFIGURE;
-- For Standard Edition, consider these additional tweaks
DBCC FREESYSTEMCACHE ('ALL');
DBCC FREESESSIONCACHE;
When errors occur randomly, implement proactive monitoring:
-- Create a memory pressure detection alert
USE msdb;
GO
EXEC msdb.dbo.sp_add_alert @name=N'SQL Server Memory Pressure',
@message_id=701,
@severity=0,
@enabled=1,
@delay_between_responses=60,
@include_event_description_in=1,
@job_name=N'Memory Pressure Response';
GO
-- Corresponding job to capture state during errors
EXEC msdb.dbo.sp_add_job @job_name=N'Memory Pressure Response';
EXEC msdb.dbo.sp_add_jobstep @job_name=N'Memory Pressure Response',
@step_name=N'Capture Diagnostics',
@subsystem=N'TSQL',
@command=N'
SELECT GETDATE() AS ErrorTime,
physical_memory_in_use_kb/1024 AS memory_in_use_mb,
locked_page_allocations_kb/1024 AS awe_memory_mb,
large_page_allocations_kb/1024 AS large_pages_mb
FROM sys.dm_os_process_memory;
SELECT TOP 10 * FROM sys.dm_os_memory_clerks
ORDER BY pages_kb DESC;
SELECT TOP 10 * FROM sys.dm_os_performance_counters
WHERE counter_name LIKE ''%Memory%''
OR object_name LIKE ''%Memory%'';
',
@database_name=N'master';
GO
When SQL Server shares resources with application/web services:
- Implement Windows System Resource Manager (WSRM) to allocate guaranteed CPU/memory to SQL Server
- Schedule resource-intensive jobs (backups, ETL) during off-peak hours
- Consider moving non-database services to a separate server if outages persist