.. _particle-cache-page:

###########
Frame Cache
###########

The component caches decoded frame data in memory for smooth playback. Configure the cache with:

.. code-block:: cpp

    // Limit cache to 512 MB
    model->setCacheMemoryLimit(512 * 1024 * 1024);

    // Query the configured limit
    size_t limit = model->cacheMemoryLimit();

    // Pre-load the next 10 frames for smooth animation
    model->preloadFrames(model->currentFrameIndex() + 1, 10);

    // Query current cache usage
    size_t usedBytes = model->cacheCurrentMemoryBytes();

The same cache API is available at the reader level via
:func:`ParticleDatasetReader::setCacheMemoryLimit() <cee::pt::ParticleDatasetReader::setCacheMemoryLimit>` and
:func:`ParticleDatasetReader::preloadFrames() <cee::pt::ParticleDatasetReader::preloadFrames>`.

To explicitly discard all cached frames (e.g. when switching scalar fields at the reader level):

.. code-block:: cpp

    reader.clearCache();
