C

MCU.Config.maxResourceCacheSize

Defines the maximum resource cache size for a runtime allocation type.

Description

This property can be used to define the maximum resource cache size for a given runtime allocation type. It can be set to either an int value representing the maximum cache size in bytes or a list of cache sizes for each AllocationType.

The resource cache is used to cache resources with the "OnDemand" cache policy. This includes all compressed resources and resources with the "OnDemand" policy. When such resources are visible, they are copied to the resource cache depending on the resource's runtime allocation type. If the cache is full, resources that have been in the cache for the longest time without being used are removed in order to accommodate the new resource.

Ensure that the maximum cache size is larger than the size of the biggest resource with the "OnDemand" cache policy. An ideal cache size should accommodate all the "OnDemand" images, which are visible at the same time. This avoids the need to decompress or copy the resources to RAM on each frame update.

For example, a 400x300 image with 32 bpp color depth occupies up to 480,000 bytes of RAM. If there could be two such images visible at the same time, and their cache policy is "OnDemand", a reasonable cache size would be 960,000 bytes.

Internally, the resource cache sizes are collected and passed to the qulrcc resource compiler in a JSON file. qulrcc tool generates C++ files with the necessary symbols needed by the Qul::Core library to know the cache sizes for each runtime allocation type.

Note: Depending on the memory allocator used, and heap memory fragmentation caused by a series of allocations and deallocations, the physical memory usage might be slightly larger than the given maximum cache size.

Usage

This property is accepted in the main application .qmlproject file, or BoardDefaults.qmlprojectconfig for the target platform. It takes an integer or an array of arrays.

Code example:

MCU.Config {
    // single value
    // maxResourceCacheSize: CacheSize
    maxResourceCacheSize: 3000
}
MCU.Config {
    // list of cache sizes per (optional) allocation type
    // maxResourceCacheSize: [ [ CacheSize, (AllocationType) ] , ... ]
    maxResourceCacheSize: [
        [1000, 128],
        [2000, 129],
        [3000]
    ]
}

Since

This property was introduced in QmlProject API 1.3.

See also Managing Resources, ImageFiles.MCU.resourceCachePolicy, ImageFiles.MCU.resourceRuntimeAllocationType, and qul_set_maximum_resource_cache_size.

Available under certain Qt licenses.
Find out more.