Skip to content

AsyncFtpClient lead to memory leak due to CancellationTokenSource #1797

@AveiShriety

Description

@AveiShriety

ver: 53.0.1
I need to syncly download ftp files to local, so I continuously fetch ftp dir and download files by using AsyncFtpClient's function[GetListing or GetListingEnumerable, DownloadFile] in 10-second intervals.
When using async class to operate ftp, it will cause A large number of newly created object [CancellationTokenSource]. I see it in vs2026's Diagnostic Tools
Image

await foreach (var item in client.GetListingEnumerable(rPath, FtpListOption.Modify)); await client.DownloadFile(dest, path, FtpLocalExists.Overwrite, FtpVerify.None);

I even define parameters [CancellationTokenSource cts]'token for these method, it also cause memory leak due to CancellationTokenSource.

So I use FtpClient instead of AsyncFtpClient by sync class. Is it a bug?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions