arthenica / ffmpeg-kit

FFmpeg Kit for applications. Supports Android, Flutter, iOS, Linux, macOS, React Native and tvOS. Supersedes MobileFFmpeg, flutter_ffmpeg and react-native-ffmpeg.
https://arthenica.github.io/ffmpeg-kit
GNU Lesser General Public License v3.0
4.53k stars 604 forks source link

Allow to clear individual sessions #1066

Open MiSikora opened 1 week ago

MiSikora commented 1 week ago

Is your feature request related to a problem? Please describe.

FFmpegSession holds a reference to FFmpegSessionCompleteCallback, which can contain any objects including the ones that have their own lifecycles. This can lead to memory leaks as sessions are retained in the history of FFmpegKitConfig. I'd like to be able to clear sessions individually from FFmpegKitConfig. Currently, the only option is to call FFmpegKitConfig.clearSessions(), which removes the entire history.

Describe the solution you'd like

A method like FFmpegKitConfig.clearSession(final String sessionId) that removes a specific session.

Describe alternatives you've considered

Alternatively, FFMpegSession could avoid holding a strong reference to FFmpegSessionCompleteCallback, or it could be possible to set the history size of FFmpegKitConfig to 0. Another option would be to not retain sessions but some sort of snapshots that do not have callbacks but this would be a breaking change.

Platform

Android

Additional context

N/A