Clean up resources - Amazon Kinesis Video Streams
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Clean up resources

In order to avoid memory leaks, do the following to unregister a media source from the client and free the client.

try { kinesisVideoClient.unregisterMediaSource(mediaSource); kinesisVideoClient.free(); } catch (final KinesisVideoException e) { throw new RuntimeException(e); }

If you added any items to the cache using the CachedInfoMultiAuthServiceCallbacks, for example:

serviceCallbacks.addStreamInfoToCache(streamName, streamInfo); serviceCallbacks.addStreamingEndpointToCache(streamName, dataEndpoint);

Clear the cache when you're done:

serviceCallbacks.removeStreamFromCache(streamName);