Home Forums .NET libraries Xceed SFTP/FTP for .NET Increasing memusage with Xceed.Ftp.FtpClient

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #20958 |

    I’m currently developing a .net windows service which is supposed to manage a number of FTP-connections to different FTP-servers. I am using the Xceed.Ftp.FtpClient for sending and receiving files and i am very pleased with the features in the xceed components. However i am having problems with increasing memusage over time. When the service has been running for exampel for 2 weeks and i look in the taskmanager it is allocating over 200 000 kB. After a number of different test to locate this memory leakage i now suspect the Xceed.Ftp.FtpClient. During an upload / download of a file the memusage increases in the program but it never seems to go down again.

    Even if i run the simple example from below i have the same problem with increasing memory usage.

    I am using VS2008 and the target framework is .net 2.0

    Does anyone have a tip for me to get rid of this problem?

    Best regards Fredrik Lindros

    ///////////////////////////////////////////////////////////////////////
    Xceed.Ftp.Licenser.LicenseKey = “XXXX-XXXX-XXXX-XXXX”;
    Xceed.Ftp.FtpClient ftp = new Xceed.Ftp.FtpClient();

    http://ftp.Connect(“HOSTNAME”, 21);
    http://ftp.Login(“USERNAME”, “PASSWORD”);
    http://ftp.ChangeCurrentFolder(“FOLDER”);

    System.IO.FileStream filestream;

    for (int i = 0; i < 100; i++)
    {
    filestream = new System.IO.FileStream(@”c:\temp\PDF.pdf”, System.IO.FileMode.Create);
    http://ftp.ReceiveFile(“PDF.pdf”, filestream);
    filestream.Flush();
    filestream.Close();
    filestream.Dispose();

    }

    http://ftp.Disconnect();

    ftp = null;
    ///////////////////////////////////////////////////////////////////////

    Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by Fredrik (had 4966 views)

    Xceed Support
    Member
    Post count: 5658

    We fixed a memory leak bug in the <a href=”http://download3.xceedsoft.com/Packages/3.2.7614.12380/XceedComponents.exe”>last version</a> of the component.

    However, if this does not fix your issue, contact us directly at <a href=”mailto:support@xceedsoft.com”>support</a> and we will investigate further.

    Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by CharlesB (had 264 views)

    User (Old forums)
    Member
    Post count: 23064

    Using SOS to analyse the library using your sample code and a ±2Mb file, there is effectivly a rising memory usage. This is caused by the fact that you dispose the stream used to transfer data, but some internal objects just don’t have time to be garbage collected.

    You can see the difference by calling GC.Collect() inside your for() loop.

    You can also check the memory using SOS extention. Here is the result before and after calling GC.Collect() just before setting the FtpClient variable to null:

    // Memory analysis before calling Garbage Collector
    !load sos
    extension C:\Windows\Microsoft.NET\Framework\v2.0.50727\sos.dll loaded
    !dumpheap -stat -type Xceed
    PDB symbol for mscorwks.dll not loaded
    total 820 objects
    Statistics:
    MT Count TotalSize Class Name
    01401844 1 12 Xceed.Ftp.Engine.FtpTracing
    0140178c 1 12 Xceed.Ftp.FtpVmsListingParser
    014016ec 1 12 Xceed.Ftp.FtpAS400ListingParser
    01401650 1 12 Xceed.Ftp.FtpUnixListingParser
    014015c8 1 12 Xceed.Ftp.FtpDosListingParser
    014053e4 1 20 Xceed.Ftp.Engine.FtpCommandChannel+AsyncReceiveState
    0140cefc 1 28 Xceed.FileSystem.EmptyFileSystemEvents
    01402cb4 1 28 Xceed.Ftp.Engine.FtpDataFormat
    01400e04 1 28 Xceed.Ftp.FtpListingParserList
    014029fc 1 32 Xceed.Ftp.ParsingListingLineEventHandler
    0140290c 1 32 Xceed.Ftp.CertificateRequiredEventHandler
    0140281c 1 32 Xceed.Ftp.CertificateReceivedEventHandler
    0140272c 1 32 Xceed.Ftp.ReplyReceivedEventHandler
    0140263c 1 32 Xceed.Ftp.CommandSentEventHandler
    00129f64 1 32 Xceed.Compression.Formats.CompressionFormatsLicense
    00128eac 1 32 Xceed.Compression.CompressionLicense
    001281ec 1 32 Xceed.FileSystem.FileSystemLicense
    00126884 1 32 Xceed.Ftp.FtpLicense
    01400ffc 1 44 Xceed.Ftp.Engine.FtpEngine
    01403da4 2 64 Xceed.Utils.Security.Ssl.CertVerifyEventHandler
    01403cb4 2 64 Xceed.Utils.Security.Ssl.CertRequestEventHandler
    014013fc 1 92 Xceed.Ftp.Engine.FtpCommandChannel
    00124aa4 1 108 Xceed.Ftp.FtpClient
    0140a3a4 12 192 Xceed.Ftp.TransferringFileEventArgs
    0140dd74 13 260 Xceed.Ftp.Engine.FtpDataConsumerCommand+CopyStreamState
    01402b44 24 288 Xceed.Ftp.RepresentationTypeOption
    0012487c 24 288 Xceed.Ftp.RepresentationType
    0140c8f0 13 364 Xceed.Ftp.Engine.ProgressionEventArgs
    0140d96c 13 416 Xceed.Utils.Streams.ClosingStreamEventHandler
    01405234 13 416 Xceed.Utils.Security.Ssl.AsyncResult
    014082fc 36 432 Xceed.Ftp.CommandSentEventArgs
    0140d824 13 520 Xceed.Utils.Streams.MemoryHandlerStream
    0140a534 13 520 Xceed.Utils.Security.Ssl.SecureNetworkStream
    01409a1c 13 572 Xceed.FileSystem.SingleFileFolder
    014057ec 50 600 Xceed.Ftp.ReplyReceivedEventArgs
    01408c0c 32 640 Xceed.Ftp.Engine.PassiveFtpDataChannel
    014084ec 13 728 Xceed.Ftp.Engine.TypeFtpCommand
    01409544 13 780 Xceed.FileSystem.StreamFile
    01408afc 13 780 Xceed.Ftp.Engine.PassiveFtpCommand
    0140a2d4 26 832 Xceed.Ftp.Engine.ProgressionEventHandler
    0140a1e4 26 832 Xceed.Ftp.TransferringFileEventHandler
    0140a0f4 26 832 Xceed.Ftp.FileTransferStatusEventHandler
    0140d0e4 13 884 Xceed.FileSystem.FileSystemEventsSession
    0140884c 13 1040 Xceed.Ftp.Engine.ReceiveFileFtpCommandSequence
    01403264 33 1188 Xceed.Utils.Security.Ssl.SecureSocket
    014056a4 52 1248 Xceed.Ftp.StringList
    01403be4 52 1248 Xceed.Ftp.FtpReply
    01409ecc 13 1300 Xceed.Ftp.FileTransferStatusEventArgs
    014086a4 13 1508 Xceed.Ftp.Engine.RetrieveFileFtpCommand
    01409c24 32 1664 Xceed.Utils.Streams.WindowStream
    0140469c 50 2000 Xceed.Ftp.Engine.FtpCommandAsyncResult
    0140389c 60 2640 Xceed.Utils.Security.Ssl.SecurityOptions
    014045d4 78 3120 Xceed.Ftp.Engine.FtpAsyncResult
    Total 820 objects

    // Force Garbage Collection
    GC.Collect()

    // Memory Analysis just after
    Expression has been evaluated and has no value
    !dumpheap -stat -type Xceed
    total 81 objects
    Statistics:
    MT Count TotalSize Class Name
    01401844 1 12 Xceed.Ftp.Engine.FtpTracing
    0140178c 1 12 Xceed.Ftp.FtpVmsListingParser
    014016ec 1 12 Xceed.Ftp.FtpAS400ListingParser
    01401650 1 12 Xceed.Ftp.FtpUnixListingParser
    014015c8 1 12 Xceed.Ftp.FtpDosListingParser
    014053e4 1 20 Xceed.Ftp.Engine.FtpCommandChannel+AsyncReceiveState
    0140cefc 1 28 Xceed.FileSystem.EmptyFileSystemEvents
    01402cb4 1 28 Xceed.Ftp.Engine.FtpDataFormat
    01400e04 1 28 Xceed.Ftp.FtpListingParserList
    014029fc 1 32 Xceed.Ftp.ParsingListingLineEventHandler
    0140290c 1 32 Xceed.Ftp.CertificateRequiredEventHandler
    0140281c 1 32 Xceed.Ftp.CertificateReceivedEventHandler
    0140272c 1 32 Xceed.Ftp.ReplyReceivedEventHandler
    0140263c 1 32 Xceed.Ftp.CommandSentEventHandler
    00129f64 1 32 Xceed.Compression.Formats.CompressionFormatsLicense
    00128eac 1 32 Xceed.Compression.CompressionLicense
    001281ec 1 32 Xceed.FileSystem.FileSystemLicense
    00126884 1 32 Xceed.Ftp.FtpLicense
    01400ffc 1 44 Xceed.Ftp.Engine.FtpEngine
    01403da4 2 64 Xceed.Utils.Security.Ssl.CertVerifyEventHandler
    01403cb4 2 64 Xceed.Utils.Security.Ssl.CertRequestEventHandler
    014013fc 1 92 Xceed.Ftp.Engine.FtpCommandChannel
    00124aa4 1 108 Xceed.Ftp.FtpClient
    01408c0c 13 260 Xceed.Ftp.Engine.PassiveFtpDataChannel
    01403264 14 504 Xceed.Utils.Security.Ssl.SecureSocket
    01409c24 13 676 Xceed.Utils.Streams.WindowStream
    0140389c 16 704 Xceed.Utils.Security.Ssl.SecurityOptions
    Total 81 objects

    if you use !gcroot to check what is using those references, you get something like this:

    Scan Thread 7988 OSTHread 1f

    Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by André (had 427 views)

    User (Old forums)
    Member
    Post count: 23064

    Thanks. Everything is working fine now after i upgraded to the latest version of the library

    Regards Fredrik

    Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by Fredrik (had 5076 views)

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.