MemoryXtend for Off-Heap RAM
MemoryXtend
Related to Data Tiering. The MemoryXtend (blobstore) storage model allows an external storage medium (one that does not reside on the JVM heap) to store the GigaSpaces Space data and is designed for operational workloads. It keeps all indexes in RAM for better performance. is NOT supported in Kubnernetes Orchestration
This is the automated configuration, management, and coordination of computer systems, applications, and services. Orchestration strings together multiple tasks in order to execute and easily manage a larger workflow or process. These processes can consist of multiple complex tasks that are automated and can involve multiple systems. Kubernetes, used by GigaSpaces, is a popular open source platform for container orchestration. Installations
Overview
The MemoryXtend off-heap storage driver stores Space
Where GigaSpaces data is stored. It is the logical cache that holds data objects in memory and might also hold them in layered in tiering. Data is hosted from multiple SoRs, consolidated as a unified data model. objects in RAM, outside the Java heap. This has two benefits:
- Better RAM utilization - Objects are stored off-heap in serialized form, which consumes less memory than the same object would use in a Java heap.
- Reduced garbage collection
Garbage collection (GC) is a form of automatic memory management. The garbage collector attempts to reclain memory that was allocated by the program, but is not longer referenced; such memory is called garbage. activity - Less data is stored on the Java heap, so the garbage collector has less work. This yields more deterministic behavior with a lower chance of experiencing stop-the-world pauses.
Off-Heap Optimization
See a code example and benchmark at: lab22-offheap_blobstore-example
The 18.0.1 update introduces advanced off-heap storage optimizations that enable the engine to read specific properties directly in place. By leveraging Java 25 Panama memory segments and embedding a per-field offset table (costing roughly 10 to 400 bytes per entry, depending on the property count), the engine can now efficiently evaluate conditions and apply projections directly against the byte block, without needing to decode the full object.
Performance Improvements and Testing Methodology
All baseline hardware measurements were conducted on an Apple Silicon laptop running JDK 25, testing the engine just before and just after the changes in alternating rounds (medians are shown).
-
Storage Layer and Query Conditions: Base storage operations are 7–24% faster (median 18%), non-indexed scans are 22% faster, and temporary garbage per write-read pair dropped 11.5x (from 4504 bytes to 392 bytes). Query conditions tested directly at the block are 2.4x faster when matching 100 entries, and 1.5x faster when matching 500,000 entries.
-
How it was tested: Measured over 7 alternating rounds using an embedded Space containing 1,000,000 entries of a narrow 6-property type. Condition metrics were based on a
readMultipleoperation targeting a non-indexed property.
-
-
Aggregation: Sum and average operations on non-indexed properties dropped from roughly 5.7 seconds to 0.86 seconds, an 85% time reduction for both embedded and remote topologies.
-
How it was tested: Measured over 6 rounds using 1,000,000 wide entries consisting of 200 properties (including a 256-byte payload). Tests were run with a 16 GB JVM
Java Virtual Machine. A virtual machine that enables a computer to run Java programs as well as programs written in other languages that are also compiled to Java bytecode. heap and the blobstore internal cache turned off.
-
-
Space Iterators: Iterators assembling a 3-property projection directly from the block saw large gains.
CURSORiteration times dropped by about 80% for embedded Spaces and about 85% for remote Spaces, whilePREFETCH_UIDSimproved by about 82% embedded and about 77% remote.-
How it was tested: Evaluated across the same 1,000,000-entry, 200-property wide dataset over 6 rounds, with a 16 GB heap and the internal cache disabled.
-
-
Off-Heap vs. Heap Gap: The performance gap between off-heap and heap reads has narrowed significantly. While off-heap reads used to cost 5–9x more than heap reads, they are now only 1.1–1.7x slower. For instance, remote aggregation dropped from 9.0x slower to just 1.34x slower than heap.
-
How it was tested: Compared using the same 1,000,000-entry, 200-property dataset on a 16 GB JVM heap.
-
Remaining Trade-Offs
-
Memory Advantage vs. Write Penalty: Off-heap memory still provides a massive footprint advantage, using 1.9 KB per entry versus 6.6 KB on the heap. However, the write penalty remains unchanged at roughly 5.0x slower for embedded Spaces and 1.7x slower for remote Spaces.
-
How it was tested: 1,000,000 wide entries (200 properties) consumed 1.9 GB off-heap instead of 6.66 GB on the heap, evaluated over 6 rounds.
-
Choosing Between Heap and Off-Heap Space
Off-heap storage is primarily used to optimize memory capacity and footprint. With the introduction of XAP
GigaSpaces eXtreme Application Platform.
Provides a powerful solution for data processing, launching, and running digital services 18.0.1, the performance gap between off-heap and heap has narrowed significantly, so targeted off-heap reads now incur minimal speed penalties.
Optimal Use Cases for Off-Heap Storage
-
Large Datasets and GC Relief: Use off-heap when the data size exceeds comfortable heap limits, or when garbage collection (GC) pressure becomes a bottleneck. Off-heap stores data several times more compactly than heap storage.
-
Targeted Reads: Off-heap performs exceptionally well when operations only require specific fields, such as aggregations, iterators that use projections, or queries with selective conditions. Under these conditions, off-heap read performance is nearly on par with heap.
When Off-Heap Storage Is Less Efficient
-
Unprojected Reads: Off-heap is slower if operations consistently fetch entire objects without applying a projection.
-
Write-Heavy Workloads: Off-heap retains a serialization write penalty, making it less optimal for applications dominated by bulk loads or frequent updates.
Important Behavior Changes
-
Projection Overwrites: Because iterators now strictly apply projections, read-modify-write loops that use projected iterators silently overwrite non-projected properties with nulls. Remove the projection, use the change API, or apply
WriteModifiers.PARTIAL_UPDATE. -
Custom Aggregators: Custom aggregators must explicitly opt in by overriding
SpaceEntriesAggregator.getAggregatedPaths()and strictly usinggetPathValue. -
Exclusions: These optimizations do not apply to SSD-based MemoryXtend (RocksDB), the blobstore internal cache, unprojected reads, or projected batch reads that use a read Space filter.
Basic Configuration
You can create a Space with the MemoryXtend off-heap storage driver via the pu configuration file, or in the code. For example, to create a Space called "mySpace' that can use up to 20GB of off-heap RAM:
This is the unit of packaging and deployment in the GigaSpaces Data Grid, and is essentially the main GigaSpaces service. The Processing Unit (PU) itself is typically deployed onto the Service Grid. When a Processing Unit is deployed, a Processing Unit instance is the actual runtime entity..xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:os-core="http://www.openspaces.org/schema/core"
xmlns:blob-store="http://www.openspaces.org/schema/off-heap-blob-store"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.openspaces.org/schema/core http://www.openspaces.org/schema/18.0.1/core/openspaces-core.xsd
http://www.openspaces.org/schema/off-heap-blob-store http://www.openspaces.org/schema/18.0.1/off-heap-blob-store/openspaces-off-heap-blob-store.xsd">
<blob-store:off-heap-blob-store id="offheapBlobstore" memory-threshold="20g"/>
<os-core:embedded-space id="space" name="mySpace">
<os-core:blob-store-data-policy blob-store-handler="offheapBlobstore"/>
</os-core:embedded-space>
<os-core:giga-space id="gigaSpace" space="space"/>
</beans>
// Create off-heap storage driver:
BlobStoreStorageHandler blobStore = new OffHeapBlobStoreConfigurer()
.setMemoryThreshold("5g")
.create();
// Create space "mySpace" with that storage driver:
EmbeddedSpaceConfigurer spaceConfigurer = new EmbeddedSpaceConfigurer("mySpace")
.cachePolicy(new BlobStoreDataCachePolicy()
.setBlobStoreHandler(blobStore));
GigaSpace gigaSpace = new GigaSpaceConfigurer(spaceConfigurer).gigaSpace();
The general MemoryXtend configuration options also apply. For example, you can configure MemoryXtend to cache some data on-heap for faster access.
For an example of how to configure the on-heap cache properties, see the MemoryXtend overview topic.
Defining the Memory Threshold
In order to use off-heap storage, you must define the amount of memory to allocate, for example. 20g. Use the following sizing units:
b- Bytesk,kb- Kilobytesm,mb- Megabytesg,gb- Gigabytes
Before any operation that requires memory allocation (write, update, and initial load), the memory manager checks how much of the allocated memory has been used. If the threshold has been breached, an OffHeapMemoryShortageException is thrown. Read, take, and clear operations are always allowed.
If you are configuring the MemoryXtend off-heap driver for GigaSpaces-based applications in Kubernetes
An open-source container orchestration system for automating software deployment, scaling, and management of containerized applications., it is recommended to define the memory threshold properties in the pu.xml as placeholders, so you can override them in the Helm chart. For more information about configuring memory allocation in Kubernetes, see XAP Skyline Kubernetes Installation.
If the used memory is below the configured threshold, then a large write operation may exceed the threshold without being blocked or throwing an exception. Users should take this into account when setting the maximum memory size. This behavior is similar to that of the regular memory manager.
Advanced Configuration
As part of fine-tuning the MemoryXtend functionality, you can control the balance between memory utilization and system performance. This is useful because there are two ways to update the value of an object in the off-heap memory:
- Free up the old memory allocation, and reallocate new memory.
- Overwrite the old value using the same allocated memory.
Deleting and reallocating memory takes longer then overwriting the same memory area, but if the size of the new value is smaller then the old value, then the overwrite option leaves part of the original allocated memory underutilized. You can use the BLOBSTORE_OFF_HEAP_MIN_DIFF_TO_ALLOCATE_PROP Space property to control when to trade off system performance for maximizing the memory usage.
This Space property works as follows: if the oldValueSize - newValueSize > blobstore.off-heap.update_threshold, then delete and reallocate memory for the object. Otherwise overwrite the old object value with the new object value.
The default threshold is 50B.
Example
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:os-core="http://www.openspaces.org/schema/core"
xmlns:blob-store="http://www.openspaces.org/schema/off-heap-blob-store"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.openspaces.org/schema/core http://www.openspaces.org/schema/18.0.1/core/openspaces-core.xsd
http://www.openspaces.org/schema/off-heap-blob-store http://www.openspaces.org/schema/18.0.1/off-heap-blob-store/openspaces-off-heap-blob-store.xsd">
<blob-store:off-heap-blob-store id="offheapBlobstore" memory-threshold="20g"/>
<os-core:embedded-space id="space" name="mySpace">
<os-core:blob-store-data-policy blob-store-handler="offheapBlobstore"/>
<os-core:properties>
<props>
<prop key="blobstore.off-heap.update_threshold">1M</prop>
</props>
</os-core:embedded-space>
<os-core:giga-space id="gigaSpace" space="space"/>
</beans>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:os-core="http://www.openspaces.org/schema/core"
xmlns:blob-store="http://www.openspaces.org/schema/off-heap-blob-store"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.openspaces.org/schema/core http://www.openspaces.org/schema/18.0.1/core/openspaces-core.xsd
http://www.openspaces.org/schema/off-heap-blob-store http://www.openspaces.org/schema/18.0.1/off-heap-blob-store/openspaces-off-heap-blob-store.xsd">
<blob-store:off-heap-blob-store id="offheapBlobstore" memory-threshold="20g"/>
<os-core:embedded-space id="space" name="mySpace">
<os-core:blob-store-data-policy blob-store-handler="offheapBlobstore"/>
<os-core:properties>
<props>
<prop key="blobstore.off-heap.update_threshold">1M</prop>
</props>
</os-core:embedded-space>
<os-core:giga-space id="gigaSpace" space="space"/>
</beans>
// Create off-heap storage driver:
BlobStoreStorageHandler blobStore = new OffHeapBlobStoreConfigurer()
.setMemoryThreshold("5g")
.create();
// Create space "mySpace" with that storage driver:
EmbeddedSpaceConfigurer spaceConfigurer = new EmbeddedSpaceConfigurer("mySpace")
.cachePolicy(new BlobStoreDataCachePolicy()
.setBlobStoreHandler(blobStore));
spaceConfigurer.addProperty("blobstore.off-heap.update_threshold", "1M");
GigaSpace gigaSpace = new GigaSpaceConfigurer(spaceConfigurer).gigaSpace();
Monitoring
The amount of used off-heap memory can be tracked using the following:
- Metrics - The
space_blobstore_off-heap_used-bytes_totalmetric, as described on the Metrics page. - Admin API - Thru SpaceInstanceStatistics.getBlobStoreStatistics()
- Web Management Console - In the Space instances view, right-click any of the columns in the table and add the Used Off-Heap column.
Additionally, you can use Ops Manager to view which services are configured for MemoryXtend at the cluster level.
In-Memory Data Grid - achieve unparalleled speed, persistence, and accuracy.