• 大小: 34KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-28
  • 语言: C#
  • 标签: 内存  泄露  

资源简介

小巧实用的内存测试的小工具,内涵C#源码

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace WindowsAppMemoryLeak
{
    public partial class frmMemoryLeakage : Form
    {

        private List objBrushes = new List(); 
        public frmMemoryLeakage()
        {
            InitializeComponent();
        }

        private void btnUnManagedLeak_Click(object sender EventArgs e)
        {
            timerManaged.Enabled = false;
            timerUnManaged.Enabled = true;
            
        }

        private void timerUnManaged_Tick(object sender EventArgs e)
        {
            Marshal.AllocHGlobal(7000);
        }

        private void btnManagedLeak_Click(object sender EventArgs e)
        {
            timerManaged.Enabled = true;
            timerUnManaged.Enabled = false;
        }

        private void timerManaged_Tick(object sender EventArgs e)
        {
            for (int i = 0; i < 10000; i++)
            {
                Brush obj = new SolidBrush(Color.Blue);
                objBrushes.Add(obj);
            }
        }

        private void frmMemoryLeakage_Load(object sender EventArgs e)
        {

        }

        private void button1_Click(object sender EventArgs e)
        {
            timerManaged.Enabled = false;
            timerUnManaged.Enabled = true;
            
        }
    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2009-09-29 08:24  WindowsAppMemoryLeak\WindowsAppMemoryLeak\
     目录           0  2009-09-25 07:29  WindowsAppMemoryLeak\WindowsAppMemoryLeak\bin\
     目录           0  2009-09-27 14:12  WindowsAppMemoryLeak\WindowsAppMemoryLeak\bin\Debug\
     文件       20480  2009-09-29 08:24  WindowsAppMemoryLeak\WindowsAppMemoryLeak\bin\Debug\WindowsAppMemoryLeak.exe
     文件       24064  2009-09-29 08:24  WindowsAppMemoryLeak\WindowsAppMemoryLeak\bin\Debug\WindowsAppMemoryLeak.pdb
     文件        5632  2005-09-23 06:56  WindowsAppMemoryLeak\WindowsAppMemoryLeak\bin\Debug\WindowsAppMemoryLeak.vshost.exe
     文件        1532  2009-09-29 08:24  WindowsAppMemoryLeak\WindowsAppMemoryLeak\Form1.cs
     文件        3693  2009-09-29 08:17  WindowsAppMemoryLeak\WindowsAppMemoryLeak\Form1.Designer.cs
     文件        6217  2009-09-29 08:17  WindowsAppMemoryLeak\WindowsAppMemoryLeak\Form1.resx
     目录           0  2009-09-27 14:12  WindowsAppMemoryLeak\WindowsAppMemoryLeak\obj\
     目录           0  2009-09-29 08:24  WindowsAppMemoryLeak\WindowsAppMemoryLeak\obj\Debug\
     目录           0  2009-09-25 07:30  WindowsAppMemoryLeak\WindowsAppMemoryLeak\obj\Debug\Refactor\
     目录           0  2009-09-25 07:29  WindowsAppMemoryLeak\WindowsAppMemoryLeak\obj\Debug\TempPE\
     文件         842  2009-09-29 08:17  WindowsAppMemoryLeak\WindowsAppMemoryLeak\obj\Debug\WindowsAppMemoryLeak.csproj.GenerateResource.Cache
     文件       20480  2009-09-29 08:24  WindowsAppMemoryLeak\WindowsAppMemoryLeak\obj\Debug\WindowsAppMemoryLeak.exe
     文件         180  2009-09-29 08:17  WindowsAppMemoryLeak\WindowsAppMemoryLeak\obj\Debug\WindowsAppMemoryLeak.frmMemoryLeakage.resources
     文件       24064  2009-09-29 08:24  WindowsAppMemoryLeak\WindowsAppMemoryLeak\obj\Debug\WindowsAppMemoryLeak.pdb
     文件         180  2009-09-27 14:12  WindowsAppMemoryLeak\WindowsAppMemoryLeak\obj\Debug\WindowsAppMemoryLeak.Properties.Resources.resources
     文件         818  2009-09-29 08:26  WindowsAppMemoryLeak\WindowsAppMemoryLeak\obj\WindowsAppMemoryLeak.csproj.FileListAbsolute.txt
     文件         498  2009-09-25 07:52  WindowsAppMemoryLeak\WindowsAppMemoryLeak\Program.cs
     目录           0  2009-09-25 07:29  WindowsAppMemoryLeak\WindowsAppMemoryLeak\Properties\
     文件        1288  2009-09-25 07:29  WindowsAppMemoryLeak\WindowsAppMemoryLeak\Properties\AssemblyInfo.cs
     文件        2869  2009-09-25 07:29  WindowsAppMemoryLeak\WindowsAppMemoryLeak\Properties\Resources.Designer.cs
     文件        5612  2009-09-25 07:29  WindowsAppMemoryLeak\WindowsAppMemoryLeak\Properties\Resources.resx
     文件        1105  2009-09-25 07:29  WindowsAppMemoryLeak\WindowsAppMemoryLeak\Properties\Settings.Designer.cs
     文件         249  2009-09-25 07:29  WindowsAppMemoryLeak\WindowsAppMemoryLeak\Properties\Settings.settings
     文件        3247  2009-09-25 07:30  WindowsAppMemoryLeak\WindowsAppMemoryLeak\WindowsAppMemoryLeak.csproj
     文件         949  2009-09-25 07:29  WindowsAppMemoryLeak\WindowsAppMemoryLeak.sln
     文件       12800  2009-09-28 23:36  WindowsAppMemoryLeak\WindowsAppMemoryLeak.suo
     目录           0  2009-09-25 07:29  WindowsAppMemoryLeak\

评论

共有 条评论