Problems with RSA.SignData
From: Chris Austin (c.austin_at_bigfoot.com)
Date: 03/24/05
- Next message: Dominick Baier [DevelopMentor]: "Re: Storing Client Certificates"
- Previous message: PierreDechaine: "Anyone out there using AzMan with WinForms solution?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Thu, 24 Mar 2005 10:18:58 -0000
Hi,
I am trying to using the RSACryptoServiceProvider.SignData function to sign
large byte arrays (from 30k to several MBs) and then write them to disk.
The problem is when I am calling the SignData method within a loop for many
arrays. In my test I am reading a series of 100 1MB files into a stream and
signing them, then writing them out again.
When running this test, it progressively uses more and more memory without
freeing any up. However if I just comment out the one line that calls
SignData, I do not have this problem. The memory is not freed until the app
is quit, even if I call GC.Collect. I have limited knowledge of using
SOS.dll for debugging, however, using this it seems that the memory is all
used up by byte arrays.
So why when I call SignData are the byte arrays not garbage collected, but
when I don't they are. Is there a bug in the SignData method that retains a
reference to the byte arrays?
Thanks for any help,
Chris
--------------------------
Private Function SignImage() As Boolean
Dim Signature() As Byte
Dim RSA As RSACryptoServiceProvider
Dim csp As CspParameters
Try
csp = New CspParameters
csp.Flags = CspProviderFlags.UseMachineKeyStore
csp.KeyContainerName = "Capgen.Capsure.SecureImage"
RSA = New RSACryptoServiceProvider(csp)
Signature = RSA.SignData(Image, "SHA1")
WriteString("<Signature>")
WriteBytes(Signature)
WriteString("</Signature>" & vbNewLine)
Signature = Nothing
Return True
Catch ex As Exception
Return False
Finally
Signature = Nothing
If Not RSA Is Nothing Then RSA.Clear()
RSA = Nothing
csp = Nothing
End Try
End Function
- Next message: Dominick Baier [DevelopMentor]: "Re: Storing Client Certificates"
- Previous message: PierreDechaine: "Anyone out there using AzMan with WinForms solution?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|