'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.
(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 tracks
sounds or sound - Sound effects
voices or voice - Voice clips
Default Image Categories
scenes or scene - Scene backgrounds
images or image - General images
characters - 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
By 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
// Only removes from memory cache (will reload faster next time from IndexedDB)
'unload music theme_song'
// Removes from both memory AND IndexedDB (will need to re-download and decode)
'unload music theme_song permanent'
// Clear all audio from persistent storage
'unload all permanent'