memleak.aspx

来自「This is a book about vb.you could learn 」· ASPX 代码 · 共 41 行

ASPX
41
字号
<%@ Import Namespace="System.Diagnostics" %>
<%@ Import Namespace="System.Text" %>

<script language="VB" runat=server>

   Sub Page_Load(Sender as Object, E as EventArgs) 
      Dim i As Integer
      Dim garbage As New StringBuilder
    
      If Application("garbage") Is Nothing Then
        Dim c As Integer

        For c=1 to 1000
          garbage = garbage.Append("xxxxxxxxxx")
        Next c

        Application("garbage") = garbage
      Else
        garbage = Application("garbage")
      End If

      For i=1 to 500
         ' Make sure we create a unique entry
         Application(i.ToString + DateTime.Now.ToString("r")) = (garbage.ToString() + DateTime.Now.ToString("r"))
      Next i

      Dim p as ProcessInfo 
      p = ProcessModelInfo.GetCurrentProcessInfo()

      ProcessID.Text = p.ProcessID.ToString()

   End Sub

</script>

<html>
   <body>
      <h2>The Process ID serving this request is: <asp:label id="ProcessID" forecolor=red runat=server/> </h2>
      <h2>There are <%=Application.Count.ToString()%> items in Application state memory.</h2>
   </body>
</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?