# RawTexture.CreateLuminanceTexture update() function cause OOM( out of memory in chrome)

**URL:** <https://forum.babylonjs.com/t/rawtexture-createluminancetexture-update-function-cause-oom-out-of-memory-in-chrome/22119>\
**Category:** Bugs\
**Tags:** material\
**Created:** [July 3, 2021, 10:11am UTC](https://forum.babylonjs.com/t/rawtexture-createluminancetexture-update-function-cause-oom-out-of-memory-in-chrome/22119 "2021-07-03T10:11:28Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![wsAndy](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/wsandy/32/16904_2.png) [@wsAndy](https://forum.babylonjs.com/u/wsAndy)\
**Post date:** [July 3, 2021, 10:11am UTC](https://forum.babylonjs.com/t/rawtexture-createluminancetexture-update-function-cause-oom-out-of-memory-in-chrome/22119/1 "2021-07-03T10:11:28Z")

</div>

Hello everyone,

I use babylon 4.2 and may find a bug. When create a raw texture by calling  
new BABYLON.RawTexture.CreateLuminanceTexture and update it by calling update() function, the memory of this raw texture will not be released and cause out of memory(OOM) finally.

It’s real strange, help!

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [July 3, 2021, 10:30am UTC](https://forum.babylonjs.com/t/rawtexture-createluminancetexture-update-function-cause-oom-out-of-memory-in-chrome/22119/2 "2021-07-03T10:30:10Z")

</div>

Welcome aboard!

Could you provide a repro in the [Playground](https://playground.babylonjs.com/)? It will be easier for us to help. Thanks!

---

<div class="post-metadata">

**Author:** ![wsAndy](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/wsandy/32/16904_2.png) [@wsAndy](https://forum.babylonjs.com/u/wsAndy)\
**Post date:** [July 5, 2021, 3:04am UTC](https://forum.babylonjs.com/t/rawtexture-createluminancetexture-update-function-cause-oom-out-of-memory-in-chrome/22119/3 "2021-07-05T03:04:26Z")

</div>

here is the PG.  
[https://playground.babylonjs.com/#67ZXQY#42](https://playground.babylonjs.com/#67ZXQY#42)

I monitor chrome memory by windows system manager

---

<div class="post-metadata">

**Author:** ![wsAndy](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/wsandy/32/16904_2.png) [@wsAndy](https://forum.babylonjs.com/u/wsAndy)\
**Post date:** [July 5, 2021, 3:24am UTC](https://forum.babylonjs.com/t/rawtexture-createluminancetexture-update-function-cause-oom-out-of-memory-in-chrome/22119/4 "2021-07-05T03:24:28Z")

</div>

Chrome version: 91.0.4472.124（64 bit）

---

<div class="post-metadata">

**Author:** ![wsAndy](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/wsandy/32/16904_2.png) [@wsAndy](https://forum.babylonjs.com/u/wsAndy)\
**Post date:** [July 5, 2021, 3:25am UTC](https://forum.babylonjs.com/t/rawtexture-createluminancetexture-update-function-cause-oom-out-of-memory-in-chrome/22119/5 "2021-07-05T03:25:25Z")

</div>

In fact, this problem only occurs in few PC.

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [July 5, 2021, 8:06am UTC](https://forum.babylonjs.com/t/rawtexture-createluminancetexture-update-function-cause-oom-out-of-memory-in-chrome/22119/6 "2021-07-05T08:06:09Z")

</div>

The PG does work for me.

Maybe your graphic card does not support the luminance format? You can try to use the red format instead (`BABYLON.RawTexture.CreateRTexture`).

---

<div class="post-metadata">

**Author:** ![wsAndy](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/wsandy/32/16904_2.png) [@wsAndy](https://forum.babylonjs.com/u/wsAndy)\
**Post date:** [July 5, 2021, 8:11am UTC](https://forum.babylonjs.com/t/rawtexture-createluminancetexture-update-function-cause-oom-out-of-memory-in-chrome/22119/7 "2021-07-05T08:11:09Z")

</div>

My GPU is RTX 2080.  
By the way, what’s the different between CreateRTexture and CreateLuminanceTexture?

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [July 5, 2021, 8:34am UTC](https://forum.babylonjs.com/t/rawtexture-createluminancetexture-update-function-cause-oom-out-of-memory-in-chrome/22119/8 "2021-07-05T08:34:35Z")

</div>

`CreateRTexture` creates a red texture, meaning a texture with only the red component. I don’t know what a luminance texture is for, I have never seen it used…

Can you reproduce the problem with the 5.0 version?

---

<div class="post-metadata">

**Author:** ![wsAndy](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/wsandy/32/16904_2.png) [@wsAndy](https://forum.babylonjs.com/u/wsAndy)\
**Post date:** [July 5, 2021, 8:38am UTC](https://forum.babylonjs.com/t/rawtexture-createluminancetexture-update-function-cause-oom-out-of-memory-in-chrome/22119/9 "2021-07-05T08:38:05Z")

</div>

Yes, this problem occurs in babylon 5.0.0 too.

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [July 5, 2021, 9:46am UTC](https://forum.babylonjs.com/t/rawtexture-createluminancetexture-update-function-cause-oom-out-of-memory-in-chrome/22119/10 "2021-07-05T09:46:47Z")

</div>

Maybe someone with a RTX2080 can test and see if they reproduce the problem…

What do you see in the Memory tab of Chrome?  
 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/3/d/3dbf9fb4877a5b9ac1da282d3fe20846a0e752b9.png)

For me the memory used does not raise much, it stays between 50 and 100MB when browsing the PG.

---

<div class="post-metadata">

**Author:** ![wsAndy](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/wsandy/32/16904_2.png) [@wsAndy](https://forum.babylonjs.com/u/wsAndy)\
**Post date:** [July 5, 2021, 10:24am UTC](https://forum.babylonjs.com/t/rawtexture-createluminancetexture-update-function-cause-oom-out-of-memory-in-chrome/22119/11 "2021-07-05T10:24:15Z")

</div>

it’s really a strange problem. We test in several rtx 2080, only two of them has OOM problem.

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [July 5, 2021, 10:26am UTC](https://forum.babylonjs.com/t/rawtexture-createluminancetexture-update-function-cause-oom-out-of-memory-in-chrome/22119/12 "2021-07-05T10:26:33Z")

</div>

Have you checked you have the same drivers on all the PC?

---

<div class="post-metadata">

**Author:** ![wsAndy](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/wsandy/32/16904_2.png) [@wsAndy](https://forum.babylonjs.com/u/wsAndy)\
**Post date:** [July 5, 2021, 10:42am UTC](https://forum.babylonjs.com/t/rawtexture-createluminancetexture-update-function-cause-oom-out-of-memory-in-chrome/22119/13 "2021-07-05T10:42:09Z")

</div>

Yes, all of them have the same GPU driver

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [July 5, 2021, 6:23pm UTC](https://forum.babylonjs.com/t/rawtexture-createluminancetexture-update-function-cause-oom-out-of-memory-in-chrome/22119/14 "2021-07-05T18:23:36Z")

</div>

Here is a topic about luminance texture [What is a Luminance Texture and How to Create? - OpenGL: Basic Coding - Khronos Forums](https://community.khronos.org/t/what-is-a-luminance-texture-and-how-to-create/71013)

I can not repro on the same chrome version with a RTX 2080 TI ☹

It mostly looks like an internal bug in the browser.

May I ask if you look into the cpu or gpu memory ??? cause your generateRandomArray would generate a lot of garbage quickly and I wonder if the cpu memory might be at cause here ?

---

<div class="post-metadata">

**Author:** ![wsAndy](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/wsandy/32/16904_2.png) [@wsAndy](https://forum.babylonjs.com/u/wsAndy)\
**Post date:** [July 6, 2021, 3:05am UTC](https://forum.babylonjs.com/t/rawtexture-createluminancetexture-update-function-cause-oom-out-of-memory-in-chrome/22119/15 "2021-07-06T03:05:45Z")

</div>

We still not find the real reason…

We use an alternative approach in [https://playground.babylonjs.com/#67ZXQY#49](https://playground.babylonjs.com/#67ZXQY#49)  
only do once memory malloc allocation and change the data in the fixed memory.

In this time, it works.
