memory leaks in pixel streaming(5.21)

I’m not sure if anyone else has experience this with pixel streaming, but I encountered the following issues:

  1. I created a project based on the FPS demo project in the Unreal Engine editor.
  2. I enabled the pixel streaming plugin and pack the project.
  3. Following the official documentation, I launched my packaged game.
  4. When I opened the stream from another browser, I noticed that the memory on the host started leaking, consuming approximately 1.3GB per hour. It continued like this until all available memory was used.

I am using Unreal Engine 5.21, and the host computer runs on either Windows Server 2022 or Windows 10. The hardware specifications are as follows: Intel Core i7-13700K processor, 32GB of memory, and an NVIDIA RTX 4090 GPU.

Hey there @JessicaLiu520! Welcome back to the community! There was a memory leak in 5.2 that was reported, that I had believed was corrected with hotfix 5.2.1 but that may or may not be the case it seems. If this is the same bug, I know with (some) certainty the current 5.3 release had corrected it as I was running into the same issue. Does this still occur on fresh 5.3 projects?

I have tried version 5.31 but encountered the same issue. I followed the documentation step by step, so how could this happen?

Ahhh then it’s an entirely different issue! It’s already sounding like it’s a pixel streaming specific issue in this case. I’m going to spin up a PS instance to see if I can replicate it. In the meantime, more questions!

Has this memory leak been present for the entirety of the project?

Is this the full shipping build or debug?

I have tested both the shipping and development modes, but there doesn’t seem to be much difference. The physical memory consistently grows at a constant speed.
I used UnrealInsights to monitor the memory between 50-200 seconds, but I didn’t observe any significant memory leaks. Here are the details of my process:

1 I created a new pure blueprint project by launching Unreal Engine 5.2.1 from the Epic Games Launcher and selecting the FPS template.
2 In the editor, I created a UV animation(make sure the video is not static) material and applied it to the floor.
3 I added the pixel streaming plugin in the editor.
4 I selected Platforms → Windows → Shipping and then packaged the project.
Following the instructions in this link: [Getting Started with Pixel Streaming in Unreal Engine | Unreal Engine 5.2 Documentation], I obtained the signal server and started the executable with the necessary parameters.
5 I played the stream on another PC (Windows 10, using Chrome) within the local network.

If you require more information or access to my test project, please let me know.

After 2 hours of reproduction, I could accrue about an extra 1gb, so it’s slow but it does seem like there is a possible memory leak with PS. Though trying to profile where its coming from has been a bit harder. I’d recommend making a report on your side:

I have already reported the bug, and the case number assigned is #00643112. Can you tell me if this issue will be addressed in the upcoming release or a hotfix? Or do you have any workarounds that I can implement in the meantime?

Currently, the ideas I have come up with involve periodically checking the memory usage and restarting the game on the server side if the memory usage reaches a critical level. Alternatively, we could consider increasing the memory capacity on our cloud host.

However, I must admit these solutions feel somewhat ugly. Do you have any other suggestions or recommendations?

Thanks for the report then! I don’t have info on what’s going to be included in the next patch, I can do a bit of digging if an issue has been put on the issues tracker, and reports have to be reviewed by an team member internally and assigned an issue in the tracker. I’ll be trying to track things on my side in the meantime.

I agree those workarounds aren’t ideal in this situation, though knowing how much a player’s average play session is you could definitely get a little extra use out of them. Unfortunately I’m not too well versed in Pixel Streaming or that portion of the source to suggest solid edits.

1 Like

确实有泄漏,5.31版本上的avcodes会频繁报错
参考:
[2023.11.02-16.49.47:597][433]LogAVCodecs: Error: Error Creating: Failed to share D3D12 Resource ensure that it is a commited Resource [D3D12 -2147024809]
[2023.11.02-16.49.47:597][433]LogAVCodecs: Error: Error Mapping: Failed to import external memory [CUDA 1]
[2023.11.02-16.49.47:597][433]LogAVCodecs: Error: Error Mapping: Failed to import external memory [CUDA 1]
[2023.11.02-16.49.47:597][433]LogAVCodecs: Error: Error Invalid State: Raw resource is invalid [CUDA]
[2023.11.02-16.49.47:597][433]LogAVCodecs: Error: Error Invalid State: Raw resource is invalid [CUDA]
[2023.11.02-16.49.47:613][436]LogAVCodecs: Error: Error Creating: Failed to share D3D12 Resource ensure that it is a commited Resource [D3D12 -2147024809]
[2023.11.02-16.49.47:614][436]LogAVCodecs: Error: Error Creating: Failed to share D3D12 Resource ensure that it is a commited Resource [D3D12 -2147024809]
[2023.11.02-16.49.47:614][436]LogAVCodecs: Error: Error Mapping: Failed to import external memory [CUDA 1]
[2023.11.02-16.49.47:614][436]LogAVCodecs: Error: Error Mapping: Failed to import external memory [CUDA 1]
[2023.11.02-16.49.47:614][436]LogAVCodecs: Error: Error Invalid State: Raw resource is invalid [CUDA]
[2023.11.02-16.49.47:614][436]LogAVCodecs: Error: Error Invalid State: Raw resource is invalid [CUDA]
[2023.11.02-16.49.47:629][439]LogAVCodecs: Error: Error Creating: Failed to share D3D12 Resource ensure that it is a commited Resource [D3D12 -2147024809]
[2023.11.02-16.49.47:629][439]LogAVCodecs: Error: Error Creating: Failed to share D3D12 Resource ensure that it is a commited Resource [D3D12 -2147024809]
[2023.11.02-16.49.47:629][439]LogAVCodecs: Error: Error Mapping: Failed to import external memory [CUDA 1]
[2023.11.02-16.49.47:629][439]LogAVCodecs: Error: Error Mapping: Failed to import external memory [CUDA 1]
[2023.11.02-16.49.47:630][439]LogAVCodecs: Error: Error Invalid State: Raw resource is invalid [CUDA]
[2023.11.02-16.49.47:630][439]LogAVCodecs: Error: Error Invalid State: Raw resource is invalid [CUDA]

我在windows server 2016、2019、2022上,都复现了,UE的版本5.31,用EPIC商场的像素流示例测试也会有问题,但是如果不用pixel streaming就没有任何问题,怀疑是编码的时候出的问题

在github上发现了一个可能的解决方案PR10637,希望尽快出小版本更新

We are currently using H.264, so this issue may not be relevant in our case. However, I was wondering when H.265 support will be available.

You should try Windows 11. It seems that Windows 11 consumes fewer GPU resources and provides better video performance. I recently upgraded my own computer from Windows 10 to 11, as well as upgraded my Moonlight and Sunshine streaming software. The GPU usage on the remote host significantly decreased, and the graphics quality improved. I was even able to play ‘DOOM Eternal’ on a remote machine.

windows server 2022好像就是win11基础的,我测试了,确实好很多,大概跑了3个小时才崩溃,之前我在2016上面基本上跑3分钟就会崩溃

我今天编一下5.31最新包含那个PR的引擎,看看我之前的这个问题会不会复现了

I tested PR10637 in version 5.2 with H.264, and it continues to create the ‘ExternalSemaphore’ object. If this object can be released, it might be a source of the leak.

Unfortunately, even though the code was committed to the repository, it missed the 5.31 version…

A solution has been confirmed:

  1. Copy the NVCodecs folder from the engine directory to your project’s Plugins folder.
  2. Modify the code according to the instructions provided in PR10637 on the Github.
  3. Update the information of the NVCodecs plugin, including the friendly name.
  4. In your editor, make sure that your version of this plugin is checked.
  5. Package your project.

These steps should resolve the memory leak issue.
But I’m uncertain if this modification is allowed by UE for commercial use.

2 Likes

这个办法好,我现在在尝试完整编译包含PR10637 的5.31引擎,太慢了,我来试试用插件的办法

我测试了5.4引擎和你提到的修改插件的方法,还是有泄漏崩溃的问题,应该是还有什么地方有问题没有修改正确

又找到两处泄漏PR11068