SecureBlackbox 16: (.NET) Why is SecureBlackbox growing the memory usage of my project?
Note: This article applies only to SecureBlackbox Legacy. For future development please consider using the latest version.
.NET memory management is efficient for most purposes, but not ideal. If you create objects and let them live in memory, they are collected. Later. When the system starts to run out of memory. Until then, the objects just pollute memory.
You can help the memory manager and garbage collector by explicitly disposing of the objects that you no longer need. To accomplish this, you can use the IDisposable interface and Dispose methods supported by most SecureBlackbox objects:
- Call the Dispose method on every object that you want to dispose.
- Set the object's variable to null/Nothing after a call to Dispose.
You do not need to call the Dispose method of inner objects owned by container classes. For example: If you add a certificate to the certificate storage, the storage class will make an internal copy. You do not need to dispose of those internal copies (the container class will do this for you) yet you will need to dispose of the certificates you added yourself, as they are not referenced in the storage class.
After you call the Dispose method, the object cannot be used anymore, even when you have a reference (or several references) to this object. So you need to ensure that you dispose of the object only when it is really not used anymore.
We appreciate your feedback. If you have any questions, comments, or suggestions about this article please contact our support team at firstname.lastname@example.org.