# 3. Memory, Compression, and Exceptions
Part of [[Web and WebGL Builds]]. Prev: [[2. Web Build Profile and Player Settings]]. Next: [[4. Publishing a Web Build]].
All values below are from the official 6000.5 **Publishing settings** and **WebAssembly Language Features** tables. They apply to the **Web** tab. Development vs release: official **Compression Format** does not affect development builds.
## 3.1 WASM heap (official defaults)
| Setting | Official 6000.5 default / note |
|---|---|
| **Initial Memory Size** | **32 MB**. If Memory Growth Mode is **None**, this is also the maximum. |
| **Memory Growth Mode** | Official recommended: **Geometric**. Also **None** (fixed) and **Linear**. |
| **Maximum Memory Size** | **2048 MB** recommended. You may enter up to **4096 MB**; official known Firefox and Chrome bugs for builds **over 2048 MB**. Only applies to Linear or Geometric growth. |
| **Linear Memory Growth Step** | Default **16 MB** (Linear only). |
| **Geometric Memory Growth Step** | Default **0.2** (heap grows by `0.2 * currentHeapSize`). |
| **Geometric Memory Growth Cap** | Default **96 MB** upper limit for one growth step. |
Start with **32 / Geometric / 2048**. Raise initial size only if the first scene cannot boot (you will see allocation failures). Raising the maximum to 4096 is not a badge of honor; official bugs exist above 2048.
## 3.2 Compression and caching
Official **Compression Format:** **Gzip**, **Brotli**, or **Disabled** (none), for **release** build files.
Official **Decompression Fallback:** include fallback decompression in the loader if you **cannot** configure server response headers for the chosen method. itch.io (and many class servers) may not let you set `Content-Encoding` the way Unity's own server docs describe. For this course, **turn Decompression Fallback on** unless you have confirmed the host sends the correct headers. A slightly larger loader is better than a page that never starts.
Official **Data caching:** cache Asset data on the user's machine via the browser **IndexedDB** API so unchanged data is not re-downloaded. Official: some browsers may ask permission or restrict large caches.
Official **Debug Symbols:** Off, External (recommended for release; symbols in a separate file), or Embedded (inside the WASM; helps demangling; larger). For a class slice, Off or External.
Official **Name Files As Hashes:** MD5 of uncompressed contents as the filename.
Official **Power Preference:** Default / Low Performance (integrated GPU) / High Performance (external GPU). Official: the browser may ignore the hint.
## 3.3 Exceptions and Wasm language features
Official **Enable Exceptions:**
- **None** - a thrown exception stops the content; best performance and smallest builds if you do not need exception support.
- **Explicitly Thrown Exceptions Only** (default) - captures `throw` and runs `finally`; generated JS is longer and slower.
- **Full Without Stacktrace** / **Full With Stacktrace** - also catch null refs and out-of-bounds; With Stacktrace adds traces and is official **debug** advice (test in a 64-bit browser). Full modes decrease performance and increase memory.
For a release class build, keep the **default** unless you have a reason.
Official also (new-project recommendations on the 6000.5 page): **Target WebAssembly 2023** enabled (disabling is "not recommended"; official browser floors are listed on that page); **Use WebAssembly.Table** enabled for new projects **without** old `.jslib` plugins that rely on `dynCall`; **Enable BigInt** enabled for new projects (official browser floors listed; disable only for older-browser compatibility). If you have leftover `.jslib` files, read the official `WebAssembly.Table` compatibility note before you toggle it.
**Enable Native C/C++ Multithreading:** official, required for some Burst / native jobs on Web, and requires `SharedArrayBuffer` plus the official multithreading prerequisites. Leave **off** for this assignment unless you have followed that manual end to end.
**Enable Submodule Stripping Compatibility:** official: leave **disabled** unless you are using the Web Stripping Tool package (otherwise code size can be worse). This series does not pin that package.
## 3.4 Diagnostics overlay
Official **Show Diagnostics Overlay** (Build Profiles > Player Settings > Publishing Settings): an icon on the build opens memory and timing data (JS heap, WASM heap, page-load timings, FPS, frame stalls). Available for Development and Release. Official: JS Memory uses `performance.memory`, currently **Chrome or Edge**; Safari / Firefox / iOS show **N/A**.
Use this when you argue about memory. Pair with [[Profiling and Optimization]] habits; a tab is not a desktop Profiler session, but the overlay is the official first instrument on Web.
## 3.5 Exercise
Set Geometric growth, 32 / 2048, Brotli, **Decompression Fallback on**, exceptions at default, Wasm 2023 / Table / BigInt on (if you have no legacy `.jslib`). Write those choices on the ship note.
## Sources
- https://docs.unity3d.com/6000.5/Documentation/Manual/class-PlayerSettingsWebGL.html