#Rendering memory leak (i guess?)

1 messages · Page 1 of 1 (latest)

teal lintel
#

Hi! I've encountered some weird problem in my game. It's built on the HDRP (17.1.0 to be exact) on Unity 6000.1.12f1. The games runs smoothly with no ram allocation problems, however when i use the Ray Traced Shadows in a realtime light source, the problems happen. If the Ray Traced Shadows option is enabled, the shadows work correctly. However, every frame there's a new memory region allocated, which leads to memory leaks. It's a scale of like 2-5mb's allocated per something about 5 seconds (the Task Manager is updating the ram usage section every 5 seconds so that's where the 5 second ram increase observation comes from). The Ray Tracing itself is not the problem, because the RTGI, reflections etc. don't cause any problems.

At first i thought the entire memory leak was caused by some faulty line in my code, however after further investigations with the Memory Profiler and WPR + WPA (Windows Performance Recorder and Analyzer) i discovered some weird stuff.

In the memory profiler, the memory is in the Untracked section. Specifically in the "Private" and "System Heaps" section.
It confused me because i didn't use any dll's that would interfer with the native memory. After trying to discover the memory leak cause by disabling / enabling most of the features in my game i came to the conclusion that the memory increases ONLY, when any Camera is enabled in my scene. That's where i started to analyze different graphics settings and at the end i found out that the Ray Traced Shadows option (of the Sun's light component in this case) is problematic. By enabling/disabling it, the ram would start leaking (when its enabled) and stop leaking (when its disabled) but without releasing the already allocated memory. Next i built the scene again in IL2CPP (non developenment windows build) and recorded the CPU and VirtualAlloc activity in WPR, then analyzed it further in WPA.

#

I selected the most linear memory growth region in the timeline

#

and then i discovered that there's some threads that increase the "Impacting Size" every frame, by something like 0,05mb or smthn like that

#

it's 0,01mb - 0,02mb per frame actually

#

most of the commit stack's are these:

#

here's the coppied commit stack section

#

Im using the WPA for the first time, sorry if i gave you some misleading information. Correct me if im wrong, but i think it might be some HDRP problem