Here is a repro:
SELECT pages_kb FROM sys.dm_os_memory_clerks WHERE type = 'USERSTORE_TOKENPERM' AND name = 'TokenAndPermUserStore'
CREATE APPLICATION ROLE rolle WITH PASSWORD = 'EveryoneKnowsThis!'
go
DECLARE @cookie varbinary(8000)
EXEC sp_setapprole N'rolle', N'EveryoneKnowsThis!', @fCreateCookie = 'true', @cookie = @cookie OUTPUT
EXEC sp_unsetapprole @cookie = @cookie
go 1000
SELECT pages_kb FROM sys.dm_os_memory_clerks WHERE type = 'USERSTORE_TOKENPERM' AND name = 'TokenAndPermUserStore'
go
DROP APPLICATION ROLE rolle
go
CREATE USER nissenils WITHOUT LOGIN
go
DECLARE @cookie varbinary(8000)
EXECUTE AS USER = 'nissenils' WITH COOKIE INTO @cookie
REVERT WITH COOKIE = @cookie
go 1000
SELECT pages_kb FROM sys.dm_os_memory_clerks WHERE type = 'USERSTORE_TOKENPERM' AND name = 'TokenAndPermUserStore'
DROP USER nissenils
go
CREATE LOGIN nissenils WITH PASSWORD = 'NotThatSecret'
CREATE USER nissenils
go
DECLARE @cookie varbinary(8000)
EXECUTE AS LOGIN = 'nissenils' WITH COOKIE INTO @cookie
REVERT WITH COOKIE = @cookie
go 1000
SELECT pages_kb FROM sys.dm_os_memory_clerks WHERE type = 'USERSTORE_TOKENPERM' AND name = 'TokenAndPermUserStore'
DROP USER nissenils
DROP LOGIN nissenils
go
DBCC FREESYSTEMCACHE('TokenAndPermUserStore')
SELECT pages_kb FROM sys.dm_os_memory_clerks WHERE type = 'USERSTORE_TOKENPERM' AND name = 'TokenAndPermUserStore'
1 Comment