> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# SetDeleteOnDestroy

> When all cache session objects corresponding to a given cache are destroyed, the cache is cleared.

When all cache session objects corresponding to a given cache are destroyed, the cache is cleared.

See **Remarks** for the ways in which a disk cache can be cleared.

## Remarks

A disk cache can be cleared in one of the following ways.

* Explicitly, by calling **SetDeleteOnDestroy** on the session object, and then releasing the session.
* Explicitly, in developer mode, by calling [ID3D12Device9::ShaderCacheControl](https://docs.xbox.com/reference/graphics/d3d12/interfaces/id3d12device9/methods/id3d12device9_shadercachecontrol_public.md) with [D3D12\_SHADER\_CACHE\_KIND\_FLAG\_APPLICATION\_MANAGED](https://docs.xbox.com/reference/graphics/d3d12/enums/d3d12_shader_cache_kind_flags_public.md).
* Implicitly, by creating a session object with a version that doesn't match the version used to create it.
* Externally, by the disk cleanup utility enumerating it and clearing it. This won't happen for caches created with the [D3D12\_SHADER\_CACHE\_FLAG\_USE\_WORKING\_DIR](https://docs.xbox.com/reference/graphics/d3d12/enums/d3d12_shader_cache_flags_public.md) flag.
* Manually, by deleting the files (`*.idx`, `*.val`, and `*.lock`) stored on disk for [D3D12\_SHADER\_CACHE\_FLAG\_USE\_WORKING\_DIR](https://docs.xbox.com/reference/graphics/d3d12/enums/d3d12_shader_cache_flags_public.md) caches. Your application shouldn't attempt to do this for caches stored outside of the working directory.

## Requirements

**Header:** d3d12\_xs.h or d3d12\_x.h\
**Library:** d3d12\_xs.lib or d3d12\_x.lib\
**Supported Platforms**: XBOX Series consoles and XBOX One family

## See Also

* [D3D12 shader cache APIs](https://microsoft.github.io/DirectX-Specs/d3d/ShaderCache.html)


## Related topics

- [D3D12_SHADER_CACHE_MODE](https://docs.xbox.com/reference/graphics/d3d12/enums/d3d12_shader_cache_mode_public.md)
- [Delete](https://docs.xbox.com/services/playfab/api-references/rest/authentication/authentication/delete.md)
- [XblMultiplayerDeleteSearchHandleAsync](https://docs.xbox.com/reference/live/xsapi-c/multiplayer_c/functions/xblmultiplayerdeletesearchhandleasync.md)
- [DestroyOwnedObject](https://docs.xbox.com/reference/graphics/d3d12/interfaces/id3d12lifetimetracker/methods/id3d12lifetimetracker_destroyownedobject_public.md)
- [PFMultiplayerDestroyMatchmakingTicket](https://docs.xbox.com/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pfmatchmaking/functions/pfmultiplayerdestroymatchmakingticket.md)
