Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 19.2 — Debugging Rounds
3D Web · Example 3 of 3

It leaks: a texture per click

renderer.info.memory.textures counts textures on the GPU right now.

Debugging rounds hand you a broken scene. Five symptoms cover most of them: it is black, it is slow, it leaks, it is blurry, it flickers. Each has a short checklist, and each check is a measurement: a pixel, a triangle count, renderer.info, the pixel ratio, a depth calculation.

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

Write a function whyBlack(renderer, scene, camera) that renders, reads the centre pixel and the triangle count, and returns the likely group of causes.

02

Write a leak test: call an action N times and fail if renderer.info.memory.textures grew by more than one.

Explain it without notes

01

Your scene is black. Give the checks you'd run, in order.

02

A configurator gets slower and slower the longer it is used. What's your hypothesis and test?

It leaks: a texture per click
Press Run to see the page.
idle

Console

Nothing logged yet.

Expected console output

leaky: new textures on the GPU after 5, 10, 15, 20 clicks: 5, 10, 15, 20
clean: new textures on the GPU after 5, 10, 15, 20 clicks: 1, 1, 1, 1
one 256 x 256 RGBA texture with mipmaps is about 341 KiB