(VCL) I have found a memory leak - global objects are not deleted.

(VCL) I have found a memory leak - global objects are not deleted.

The leaks you have noticed are not leaks actually. During its work, SecureBlackbox creates several global objects that must reside in memory until the application terminates (cryptographic core objects). When the process is destroyed, the objects are freed by the operating system anyway.

We do not destroy the objects manually (in finalization sections), as this might cause certain problems with multi-threaded applications. Delphi provides no guaranteed way to detect the sequence of execution of finalization sections of different units, so there can be a situation that some object attempt to access to a core object after the latter has been destroyed.

If you need to use the components within a DLL (that can be unloaded without termination of the host process), please use SBUtils.CleanupRegisteredGlobalObjects() function to release the memory allocated for the core objects. Actually, you can use it not only from a DLL but from a generic application too, however, as mentioned, we do not recommend it, as using this function can lead to hard-to-trace bugs and crashes on application shutdown.

Ready to get started?

Learn more about SecureBlackbox or download a free trial.

Download Now