Unload
Free up memory by unloading unused assets
Description
'unload <type> [asset] [permanent]'
'unload character <id> [sprite] [permanent]'
'unload block <block_id> [permanent]'
'unload all [permanent]'The unload action allows you to release assets from memory when they are no longer needed. This is crucial for managing memory usage in long games or games with many high-resolution assets.
Action ID: Unload
Reversible: No (Reverting does nothing)
Requires User Interaction: No
Parameters
type
The category of the asset (see Supported Categories below).
asset
(Optional) The specific asset to unload. If omitted, all assets of the specified type will be unloaded.
id
When unloading a character, the character's ID.
sprite
(Optional) When unloading a character, the specific sprite to unload. If omitted, all sprites for the character are unloaded.
block_id
When using unload block, the ID of the preload block to unload.
all
Special keyword to unload ALL cached assets.
permanent
(Optional) If included, audio assets will also be removed from persistent storage (IndexedDB).
Supported Categories
The unload action supports the same categories as the Preload action:
Default Audio Categories
music- Background music trackssoundsorsound- Sound effectsvoicesorvoice- Voice clips
Default Image Categories
scenesorscene- Scene backgroundsimagesorimage- General imagescharacters- Character sprites (uses special syntax, see examples)
Note: Singular forms (sound, voice, scene, image) are aliases for their plural counterparts.
Examples
Unload a specific song
Unload all scenes
Unload a specific character sprite
Unload all sprites for a character
Unload a block of assets
Unload everything (e.g., at end of chapter)
The permanent Flag
permanent FlagBy default, unload only removes assets from the in-memory cache. For audio assets, the decoded audio buffers are also stored in IndexedDB for faster loading in future sessions.
Adding the permanent flag will also remove audio assets from IndexedDB:
This is useful when:
The player has completed a section and won't return
You want to free up storage space
You're updating assets and need to force a fresh download
Memory Management Best Practices
Chapter-based Unloading
For games with distinct chapters or scenes, use preload blocks and unload them when no longer needed:
Unloading Unused Characters
When characters leave the story permanently:
Full Memory Clear
At major story transitions:
Related Actions
Preload - Load assets into memory before they're needed
Last updated
Was this helpful?