A robot developer may configure DDS HISTORY depth to 100 and conclude that every keyed instance has a 100-sample buffer. That conclusion is incomplete. HISTORY describes which samples the service should keep, while RESOURCE_LIMITS bounds how many samples and instances the service may allocate. The effective behavior comes from both policies, the number of active keys, RELIABILITY, and whether the limit is reached at a writer or reader.

What HISTORY requests

DDS HISTORY has KEEP_LAST and KEEP_ALL kinds. KEEP_LAST retains the most recent depth samples for each instance, replacing older samples as new values arrive. KEEP_ALL attempts to keep all samples until they can be delivered or taken, subject to resource limits. A depth of 100 under KEEP_LAST expresses a per-instance history objective. It does not reserve 100 slots for every possible key by itself.

RESOURCE_LIMITS provides three major bounds: max_samples across the entity, max_instances, and max_samples_per_instance. LENGTH_UNLIMITED can remove a specific configured limit, although real machines still have finite memory. DDS requires consistent values. HISTORY depth must be less than or equal to max_samples_per_instance, and max_samples must be at least max_samples_per_instance. An entity creation or set_qos call with inconsistent values should fail.

Consistency is not capacity planning

A configuration can pass those checks and still lack room for the intended worst case. Suppose a reader uses KEEP_LAST depth 100, max_samples_per_instance 100, max_instances 50, and max_samples 500. Each individual limit is syntactically plausible, but 50 fully populated instances would require 5,000 sample slots. The global max_samples of 500 can accommodate an average of only ten samples per instance if all 50 keys are active at once.

The DDS 1.4 specification explicitly discusses cases in which max_samples is less than max_instances multiplied by HISTORY depth. When the global pool is exhausted, the service may need to discard samples from other instances while keeping at least one sample for an instance, or a reliable writer may block. The precise outcome depends on the entity, reliability, implementation, and current allocation. A dashboard that saw a 100-depth setting should not assume that every joint or robot maintained 100 historical values.

Reliability changes pressure, not memory

With BEST_EFFORT reliability, old values may be discarded when limits prevent storage. With RELIABLE reliability, a DataWriter can block while waiting for space to deliver necessary old values. The writer's max_blocking_time limits how long write may wait. If it cannot store the modification before that time, write can return TIMEOUT. Under conditions where waiting cannot free resources, the service may return OUT_OF_RESOURCES instead.

This matters in robot control loops. A write call that usually takes microseconds can stall when a reliable reader is slow and the writer history is full. If that call runs on a real-time control thread, the middleware backpressure can disturb the loop. Separate communication from control execution, bound blocking time, and handle error returns rather than assuming write always succeeds.

Readers face a different failure mode. If the application does not take samples promptly, the reader cache can reach its limits. New data can be rejected or samples can be lost depending on policies and circumstances. Monitor SampleRejectedStatus and SampleLostStatus and record the reason. Queue depth alone does not reveal whether loss occurred at the writer, transport, reader cache, or application boundary.

Calculate a working capacity model

Start with the expected and maximum number of active keyed instances. Multiply by the desired retained depth, then add headroom for discovery, lifecycle transitions, bursts, and late consumers. Compare that number with max_samples and max_samples_per_instance on both writers and readers. Account for sample payload size, metadata, alignment, and implementation overhead when translating slots into memory.

For example, a fleet status topic may have 200 robot keys, a desired depth of 20, and 2 KiB payloads. The payload alone is roughly 8 MiB for 4,000 samples, before middleware overhead. A max_samples value of 1,000 cannot provide depth 20 to every active robot. If only 25 robots are usually online, the system may look healthy in routine tests and fail during a full-fleet exercise.

Choose separate topics or readers when retention needs differ. A controller may need only the latest command per actuator, while a diagnostic recorder needs a deeper history. Putting both needs into one large cache can increase blocking risk and memory use. DDS QoS can be tailored per DataReader and DataWriter, but compatible endpoints still need a deliberate end-to-end budget.

Test allocation boundaries

Create the maximum number of instances, fill each to the requested depth, and observe memory, write latency, and status callbacks. Repeat with one slow reliable reader, one disconnected reader, and BEST_EFFORT delivery. Force max_samples exhaustion and verify whether writes block, time out, return out-of-resources, or cause reader-side rejections. Test instance churn, because registered but inactive keys can consume limits differently from never-seen keys.

Also verify configuration failures. Set depth above max_samples_per_instance and confirm that entity creation or set_qos fails visibly. Do not silently replace an invalid operator setting with a smaller value. A rejected configuration is easier to diagnose than an undisclosed capacity downgrade.

Observe the effective history

Expose metrics per entity: active instances, allocated sample count, high-water mark, write blocking duration, timeouts, out-of-resource returns, rejected samples, lost samples, and application take latency. During incident review, capture the exact HISTORY, RESOURCE_LIMITS, and RELIABILITY settings from both endpoints.

HISTORY depth answers what the application wants retained per instance. RESOURCE_LIMITS answers how much the service is allowed to allocate. Reliable delivery can turn an exhausted cache into backpressure, while best-effort delivery can turn it into loss. Size and test all three policies together so a robot's apparent 100-sample history is a demonstrated capacity, not just a number in a configuration file.