ShawInnes / SshKeyGenerator

DotNet Core implementation of SSH Key Generator
MIT License
39 stars 13 forks source link

Memory leakage #5

Closed joerage closed 3 years ago

joerage commented 3 years ago

Because the RSACryptoServiceProvider object is never disposed, program using this library will suffer from memory leak. This can easily be seen using this small sample program and watching its memory grow.

while (true)
{
  var keygen = new SshKeyGenerator.SshKeyGenerator(2048);
  var publicSshKey = keygen.ToRfcPublicKey();
}

Note that RSACryptoServiceProvider contains unmanaged resources.

ShawInnes commented 3 years ago

Nice catch. Thanks for the PR