'
' 开关:默认不启用,访问参数 ?memlog=1 可临时开启;
' 如需全站常驻开启,把 EnableAutoMemoryLog 改为 True。
Const EnableAutoMemoryLog = False
Const AutoLogTopN = 50
Const AutoLogThresholdKB = 65536 ' 64MB
Sub AutoMemoryLog(db)
On Error Resume Next
If db Is Nothing Then Exit Sub
Dim enable: enable = EnableAutoMemoryLog Or (LCase(Request("memlog")) = "1")
If Not enable Then Exit Sub
' 1) 写入数据库日志表(依赖 install_memory_log.sql 中的对象)
db.Execute "EXEC dbo.LogHighMemoryGrants @Top=" & AutoLogTopN & ", @RequestedKBMin=" & AutoLogThresholdKB
If Err.Number <> 0 Then
' 静默失败,避免影响页面;可改为写入文本
Err.Clear
End If
On Error Goto 0
End Sub
%>