Adding new memory trimming to more forcefully return memory to the OS after major memory clearing events (i.e. clearing all cache, closing readers, or large amounts of cache cleared). Also, refactoring default cache sizes in Timeline, FrameMapper, and FFmpegReader to better support high frame rate and high resolution videos (i.e. 4k 60 fps) so we don't immediately run out of memory.

This commit is contained in:
Jonathan Thomas
2025-12-14 23:53:36 -06:00
parent 1f06f03e9c
commit 7fdd145dc2
10 changed files with 156 additions and 18 deletions

View File

@@ -17,6 +17,7 @@
#include "FrameMapper.h"
#include "Exceptions.h"
#include "Clip.h"
#include "MemoryTrim.h"
#include "ZmqLogger.h"
using namespace std;
@@ -745,6 +746,9 @@ void FrameMapper::Close()
SWR_FREE(&avr);
avr = NULL;
}
// Release freed arenas back to OS after heavy teardown
TrimMemoryToOS(true);
}
@@ -841,7 +845,7 @@ void FrameMapper::ChangeMapping(Fraction target_fps, PulldownType target_pulldow
final_cache.Clear();
// Adjust cache size based on size of frame and audio
final_cache.SetMaxBytesFromInfo(OPEN_MP_NUM_PROCESSORS, info.width, info.height, info.sample_rate, info.channels);
final_cache.SetMaxBytesFromInfo(24, info.width, info.height, info.sample_rate, info.channels);
// Deallocate resample buffer
if (avr) {