I am using Opencvsharp library and running a WPF Desktop application where i load image with 20/25 faces . Run face detection on this image and after that execute emotion analysis on these detected faces based on onnx ml model . this functions execute every 5 seconds . every 10 seconds to release unmanaged resources i run.
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
the issue is the program run fine for 1.5/2 hours . after that memory increases gradually . memory is also released periodically . but the memory increases at a much more rate than it releases . After 3 or 4 hours the memory reaches to almost 10 gb and applications crashes with failed memory allocation exception message . one thing i have noticed with single face image memory pressure is better than 25 faces images . it also increased by almost 1 gb but it never exceeds absurd amount of memory . has anyone faced similar kind of problem ?
Environment
windows 10 and windows 11 version 64 bit
Visual Studio 2019 . net framework 4.7.2 . WPF desktop application