memleak.aspx

来自「Professional ASP.NET source code」· ASPX 代码 · 共 41 行

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

<script Language="C#" runat=server>

   void Page_Load(Object Sender, EventArgs E) 
   {
      int i;
      StringBuilder garbage = new StringBuilder();
    
      if (Application["garbage"] == null)
      {
        for (int c=1; c<=1000; c++)
          garbage = garbage.Append("xxxxxxxxxx");

        Application["garbage"] = garbage;
      }
      else
        garbage = (StringBuilder)Application["garbage"];

      for (i=1; i<=500; i++)
      {
         // Make sure we create a unique entry
         Application[i.ToString() + DateTime.Now.ToString("r")] = (garbage.ToString() + DateTime.Now.ToString("r"));
      }

      ProcessInfo  p;
      p = ProcessModelInfo.GetCurrentProcessInfo();

      ProcessID.Text = p.ProcessID.ToString();

   }

</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 + -
显示快捷键?