mlx.core.metal.set_cache_limit#

set_cache_limit(limit: int) int#

Set the free cache limit.

If using more than the given limit, free memory will be reclaimed from the cache on the next allocation. To disable the cache, set the limit to 0.

The cache limit defaults to the memory limit. See set_memory_limit() for more details.

Parameters:

limit (int) – The cache limit in bytes.

Returns:

The previous cache limit in bytes.

Return type:

int