Nanfeng

Notes on software development, code, and curious ideas

Why Cocos Creator Texture Memory Differs from Image File Size

In Cocos Creator, the amount of memory used by a cached texture may differ significantly from the image file’s size on disk. Several types of processing and optimization can explain the difference.

Compression

Game engines may use GPU texture-compression formats such as ETC, PVRTC, or ASTC. Each format has a different memory cost and platform support profile. Also remember that a compressed PNG or JPEG file on disk may expand into a much larger uncompressed pixel format in memory.

Mipmaps

The engine may generate progressively smaller versions of the original texture. Mipmaps improve rendering quality and sampling at a distance, but the additional levels consume more texture memory.

Texture format

Formats such as RGBA8888 and RGB565 require different numbers of bytes per pixel. The format selected for a target platform therefore affects the final memory usage.

Dynamic batching and atlases

Cocos Creator may combine smaller textures or sprite frames into a larger atlas to reduce draw calls. Padding, atlas dimensions, and duplicated or retained source textures can make the reported cache size differ from any individual image.

Use the browser or platform developer tools and the engine’s profiler to inspect actual texture memory. The precise result depends on the Cocos Creator version, target platform, import settings, and build configuration, so consult the documentation for the version used by your project when investigating a specific case.

+