SharePoint Server Out Of Memory.
Applies to: SharePoint, Azure SQL Server VM, Microsoft SQL Server 
2008 R2.
Date created: December 6, 2019.
 
Problem Description.
 
Business users using a SharePoint application were receiving the following 
error in Spanish language:
Memoria insuficiente en el servidor. Memoria 
insuficiente en 
el servidor para ejecutar el programa. Póngase en contacto con el
administrador para solucionar el problema. 0x8007000e
Translated to English the error should read like:
Server Out Of Memory. There is no memory
on the server to run your program. Please contact your
administrator with this problem. 0x8007000e

On the SQL Server instance serving this SharePoint farm we were seeing blocking 
chains of up to 17 sessions involved, and all of these sessions running dbo.TempGetStateItemExclusive3. 
Inside dbo.TempGetStateItemExclusive3 the following UPDATE statement was blocked 
on all executions of dbo.TempGetStateItemExclusive3.
 
UPDATE [SharePointSession].dbo.ASPStateTempSessions SET Expires = DATEADD(n, 
Timeout, @now), LockDate = CASE Locked WHEN 0 THEN @now ELSE LockDate END, 
LockDateLocal = CASE Locked WHEN 0 THEN @nowLocal ELSE LockDateLocal END, @lockAge 
= CASE Locked WHEN 0 THEN 0 ELSE DATEDIFF(second, LockDate, @now) END, @lockCookie 
= LockCookie = CASE Locked WHEN 0 THEN LockCookie + 1 ELSE LockCookie END, @itemShort 
= CASE Locked WHEN 0 THEN SessionItemShort ELSE NULL END, @textptr = CASE Locked 
WHEN 0 THEN TEXTPTR(SessionItemLong) ELSE NULL END, @length = CASE Locked WHEN 0 
THEN DATALENGTH(SessionItemLong) ELSE NULL END, @locked = Locked, Locked = 1, /* 
If the Uninitialized flag (0x1) if it is set, remove it and return 
InitializeItem (0x1) in actionFlags */ Flags = CASE WHEN (Flags & 1) <> 0 THEN 
(Flags & ~1) ELSE Flags END, @actionFlags = CASE WHEN (Flags & 1) <> 0 THEN 1 
ELSE 0 END WHERE SessionId = @id 
 
Cause.
The problem was that sometimes the sessions remained blocked in the ASPState 
database, resulting in many calls per second to dbo.TempGetStateItemExclusive3 
for each of the blocked sessions.
The CPU consumption on the IIS server will increase eventually with the increase 
of blocked sessions.
After analizing logs on the IIS servers a HTTP 500 error was found after the 
session state has been locked (during the REQUEST_ACQUIRE_STATE phase), but 
since the REQUEST_RELEASE_STATE phase doesn't happen, the session lock isn't 
released.
 
Workaround.
You could try recycling your the application pool which hosts your app.
Solution.
Run the following command on the Web server:
c:\windows\system32\inetsrv\appcmd.exe set config "sitename" -section:system.webServer/serverRuntime 
/uploadReadAheadSize:"0" /commit:apphost
For IIS 7.5 or higher place this line in Web.config:
<system.webServer>
<serverRuntime uploadReadAheadSize="0" />
</system.webServer>