Skip to content

High memory allocation using SshCommand #1776

@Levi--G

Description

@Levi--G

Hi,

I noticed using SSH.Net there are a few issues using SshCommand:

  • Allocation of 2kB of buffer for every command, even short ones without output and without monitoring output
  • Not reading output causes these buffers to grow indefinitely for long running commands
  • No way to discard this output easily
  • Using sshcommands many at a time in a pool causes huge GC pressure with the many large allocations

An example from a single command running without cleaning the streams shows it allocating over 300kB of memory in a VS snapshot.

Possible solutions:

  • Allocate the pipestreams only when accessed, discarding input otherwise (breaking change)
  • Creating a new sshcommand that does not allocate.

I will be creating a pull request for scenario 2 as i need a solution for a project asap.

Thanks for the library!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions