[id='configuring-memory-off-heap_{context}']
= Configuring off-heap memory

Configure {brandname} to store cache entries in native memory outside the JVM
heap space.

.Procedure

. Open your {brandname} configuration for editing.
. Set `OFF_HEAP` as the value for the `storage` attribute or `storage()` method.
. Set a boundary for the size of the cache by configuring eviction.
. Save and close your {brandname} configuration.

[discrete]
== Off-heap storage

{brandname} stores cache entries as bytes in native memory.
Eviction happens when there are 100 entries in the data container and {brandname} gets a request to create a new entry:

.XML
[source,xml,options="nowrap",subs=attributes+,role="primary"]
----
include::xml/off_heap_memory.xml[]
----

.JSON
[source,json,options="nowrap",subs=attributes+,role="secondary"]
----
include::json/off_heap_memory.json[]
----

.YAML
[source,yaml,options="nowrap",subs=attributes+,role="secondary"]
----
include::yaml/off_heap_memory.yaml[]
----

.ConfigurationBuilder
[source,java,options="nowrap",subs=attributes+,role="secondary"]
----
include::code_examples/OffHeapMemory.java[]
----

[role="_additional-resources"]
.Additional resources
* link:{configdocroot}[{brandname} configuration schema reference]
* link:{javadocroot}/org/infinispan/configuration/cache/MemoryConfigurationBuilder.html[org.infinispan.configuration.cache.MemoryConfigurationBuilder]
