# ShaderCompileWorker eats memory like crazy

**URL:** <https://forums.unrealengine.com/t/shadercompileworker-eats-memory-like-crazy/301442>\
**Category:** Platform & Builds\
**Tags:** Linux, shadercompileworker, unreal-engine, question\
**Created:** [December 12, 2014, 10:57pm UTC](https://forums.unrealengine.com/t/shadercompileworker-eats-memory-like-crazy/301442 "2014-12-12T22:57:53Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Slonopotamus](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Slonopotamus](https://forums.unrealengine.com/u/Slonopotamus)\
**Post date:** [December 12, 2014, 10:57pm UTC](https://forums.unrealengine.com/t/shadercompileworker-eats-memory-like-crazy/301442/1 "2014-12-12T22:57:53Z")

</div>

During initial editor startup when it compiles lots of shaders, I observe ShaderCompileWorker processes steadily growing up to 2GB+ RAM each while they compile shaders (after what I have to shutdown editor due to insufficient RAM). On Windows, ShaderCompileWorker are almost always under 100MB. So, is it a leak that should be fixed or there is a really strong reason why OpenGL shader compilation should take 20x RAM more than DirectX?

---

<div class="post-metadata">

**Author:** ![amigo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@amigo](https://forums.unrealengine.com/u/amigo)\
**Post date:** [December 13, 2014, 12:24am UTC](https://forums.unrealengine.com/t/shadercompileworker-eats-memory-like-crazy/301442/2 "2014-12-13T00:24:04Z")

</div>

I thought that we had these leaks sorted out way back when…

There were couple of major leaks in hlslcc that we patched, but come to think of it after submitting so many PRs I don’t remember if that specific one was ever incorporated or not.

If you have the time and inclination, please send a PR with a fix and I’ll pest0r RCL to add it in. SCW should definitely not eat 2GB+ of RAM.

---

<div class="post-metadata">

**Author:** ![Slonopotamus](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Slonopotamus](https://forums.unrealengine.com/u/Slonopotamus)\
**Post date:** [December 13, 2014, 9:49am UTC](https://forums.unrealengine.com/t/shadercompileworker-eats-memory-like-crazy/301442/3 "2014-12-13T09:49:10Z")

</div>

> I thought that we had these leaks sorted out way back when…

I don’t believe others who play with UE on Linux don’t notice 3-5 (depending on number of cores) processes each eating 2GB+ RAM.

Whatever, I’l try to valgrind this beast.

---

<div class="post-metadata">

**Author:** ![amigo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@amigo](https://forums.unrealengine.com/u/amigo)\
**Post date:** [December 13, 2014, 4:01pm UTC](https://forums.unrealengine.com/t/shadercompileworker-eats-memory-like-crazy/301442/4 "2014-12-13T16:01:33Z")

</div>

We ran SCW through valgrind and found couple of major memory leaks in hlslcc. They were patched in my 4.4-linux branch, and iirc I did submit PR upstream to Epic for those.

I’m not sure what happened afterwards, as Epic made further changes to SCW and more integration of hlslcc into the engine occurred as well.

---

<div class="post-metadata">

**Author:** ![amigo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@amigo](https://forums.unrealengine.com/u/amigo)\
**Post date:** [December 13, 2014, 7:44pm UTC](https://forums.unrealengine.com/t/shadercompileworker-eats-memory-like-crazy/301442/5 "2014-12-13T19:44:06Z")

</div>

I forgot to include a link to my branch, so here is the commit for the hlslcc leaks identified back in 4.4 days [https://github.com/3dluvr/UnrealEngine/commit/f9911a3f713409add857ea3869d100ff7cf11ea3](https://github.com/3dluvr/UnrealEngine/commit/f9911a3f713409add857ea3869d100ff7cf11ea3)

---

<div class="post-metadata">

**Author:** ![Slonopotamus](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Slonopotamus](https://forums.unrealengine.com/u/Slonopotamus)\
**Post date:** [December 13, 2014, 9:23pm UTC](https://forums.unrealengine.com/t/shadercompileworker-eats-memory-like-crazy/301442/6 "2014-12-13T21:23:24Z")

</div>

Thanks, I’ll work on pushing this upstream.
