Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 6.6 — Texture Memory
3D Web · Example 2 of 2

Textures rising and falling with dispose()

MeshBasicMaterial is used so the count starts at 0 (a Standard material adds one lookup table). The last two lines: a texture disposed while still in the scene comes back at the next render.

A texture costs width × height × 4 bytes on the GPU, plus a third for mipmaps, whatever its file size. renderer.info.memory.textures counts them, and dispose() frees them.

Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.

Ready for more? This phase has 4 hands-on exercises with automatic checks.

Practice questions

Write the code in the editor, run it, then open the model answer to compare.

01

Your showroom uses 12 textures of 2048 × 2048 with mipmaps. What is the total, and is it a problem?

02

Write the code that changes a mesh's colour map and frees the old one.

Explain it without notes

01

A texture is a 300 KB JPEG at 2048 × 2048. How much GPU memory does it take, and how do you cut it?

02

What does renderer.info.memory.textures tell you, and what does it not?

Textures rising and falling with dispose()
Press Run to see the page.
idle

Console

Nothing logged yet.

Expected console output

created 6 textures, nothing drawn yet: 0
after the first render(): 6
removed 3 cards and disposed their textures: 3
disposed a texture that is still used: 2
after the next render(): 3 (it was uploaded again)