There is the following code, which should create 16 million elements (in this case, only 4k, you need to replace 16 * 16 * 16 with 16 * 16 * 16 * 16 * 16 * 16). And after 5 million somewhere chrome eats all the RAM and that's it. Where is the leak? What to do?
const body = document.querySelector('body'); for (let i = 0, l = 16*16*16; i < l; i++) { const el = document.createElement('div'); el.style.backgroundColor = '#' + addZero(6, i.toString(16)); body.appendChild(el); } function addZero(digits_length, source){ while(source.length < digits_length) source = '0' + source; return source; } body { display: flex; flex-wrap: wrap; margin: 0; padding: 0; } div { width: 1px; height: 1px; }