计时器内存泄漏UDP接收器

嗨,大家好,我在运行计时器时发生内存泄漏,以使标签更新为从服务器接收的数据

UdpClient client = new UdpClient(15000);
    string data;
    private void timer1_Tick(object sender, EventArgs e)
    {

        client.BeginReceive(new AsyncCallback(recv), null);
        if (label1.Text.Contains("name")) 
          { label1.Text =data + "   Receiver Name is " + Environment.MachineName; }




    }

    private void Form1_Load(object sender, EventArgs e)
    {
        timer1.Start();

    }
    void recv(IAsyncResult res)
    {

        IPEndPoint ep = new IPEndPoint(IPAddress.Any, 15000);
        byte[] recived = client.EndReceive(res, ref ep);
        data = Encoding.UTF8.GetString(recived);
        this.Invoke(new MethodInvoker(delegate { label1.Text = data; }));

    }

我该如何解决?感谢和抱歉我的英语

评论