irajsb / UE_CaptureSubsystem

Runtime video and screenshot capture system for Unreal Engine
MIT License
91 stars 15 forks source link

Memory not freed after destruction of CaptureSubsystemDirector #10

Closed LukaPerovic closed 8 months ago

LukaPerovic commented 8 months ago

Hi. When capturing for longer periods of time, the RAM starts to fill up. This is especially noticeable when capturing at 120 fps, where the RAM fills up at around 200MB/s. This isn't surprising. However, after ending capture, the memory that was used up is not freed. memorija This is the graph of my RAM, total memory usage is pretty constant, then during capturing it rises up quickly, and then stays static again. I tried debugging this, and the program calls the Encode_Finish method of the CaptureSubsystemDirector at the end of the capturing, where it seems that most of the memory should be freed. The UE5 project used is just the default Third Person Game, and the only code is this blueprint_code Just to note, I've tried running the same code with the output file being the recommended video file name instead of an RTMP stream link, and the issue persists. Also, the same issue is present when capturing at 30 fps, albeit slower. Related question: Is there any way to free up memory during capturing in the case of encoding an RTMP stream, or is there a recommended method of doing this in an alternate way instead of just one continuous stream, as my goal is to make a live stream of an Unreal Engine application?

irajsb commented 8 months ago

I Received this and Will start inspecting soon

irajsb commented 8 months ago

Pushed an update. Now memory doesn't rise in the first place (each frame is freed instantly after getting encoded as it should and intended). 120 fps is not a good idea if you plan to send data over an stream unless you are 100% sure that both server and watcher are capable of transmitting such data

LukaPerovic commented 8 months ago

Thanks for the quick fix! It seems to be working great. I'm not planning on streaming in 120 fps - I was just tinkering with the settings to see the difference in quality.