Advanced Usage
Memory Management
The SDK, when used, allocates an important chunk of resources in order to process the signature into the provided images.
Those resources can be freed up once you know that no interaction with SashaSDK
is needed for some time.
- iOS
- Android
sashaSDK.cleanup()
When you receive SashaSDK.Signing.Output
the reference to the image can be an optimized memory representation of the image via CIImage
.
Any further transformation of the image bears your responsibility for memory management, but SashaSDK
does not hold any in-memory representation of the source
or processed
images.
Calling cleanup() removes all data and processing performed during prepare(). After calling cleanup(), you'll need to run prepare() again before using the SDK.
sashaSDK.cleanup()
When you receive a EmbeddedSignature
, it contains the signed image data as a PixelBufferData
object. If you convert this data to a Bitmap
using the provided .toBitmap()
extension function, it is your responsibility to manage its memory.
Ensure you recycle the Bitmap
when it is no longer needed to avoid memory leaks.
val signedBitmap = response.data.toBitmap()
// ... use the bitmap ...
if (signedBitmap != null && !signedBitmap.isRecycled) {
signedBitmap.recycle()
}
Preemptive Warm Up
- iOS
- Android
For better performance, prepare / warm up the SDK:
// Preemptively prepare SashaSDK
sashaSDK.prepare()
If you don't run prepare, it will be run for you when doing embedSignature() and lookupSignature().
For better performance, prepare up the SDK:
// Preemptively prepare SashaSDK
sashaSDK.prepare()
This prepares the SDK's internal components for embedding and lookup operations.
- This method must be called after calling
init
and before any signing or lookup operations to have any effect. - Calling this method is optional. If the SDK is not prepared before calling
embedSignature
orlookupSignature
, it will be prepared automatically as part of that operation.