# What is the limit on heap memory state store can use?

**URL:** https://forum.confluent.io/t/what-is-the-limit-on-heap-memory-state-store-can-use/10425
**Category:** Kafka Streams
**Created:** [21 March 2024 05:47 UTC](https://forum.confluent.io/t/what-is-the-limit-on-heap-memory-state-store-can-use/10425 "2024-03-21T05:47:52Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![shrenikjain](https://avatars.discourse-cdn.com/v4/letter/s/bb73d2/32.png) [@shrenikjain](https://forum.confluent.io/u/shrenikjain)
#### Post date: [21 March 2024 05:47 UTC](https://forum.confluent.io/t/what-is-the-limit-on-heap-memory-state-store-can-use/10425/1 "2024-03-21T05:47:52Z")

</div>

I am running kafka-streams application where I see the heap usage keeps increasing with the size of state store. How can I limit the heap usage of state store?

Note: In my application by nature the data will not get compacted as each message is has unique key.

---

<div class="post-metadata">

### Author: ![lbrutschy](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/lbrutschy/32/2371_2.png) [@lbrutschy](https://forum.confluent.io/u/lbrutschy)
#### Post date: [25 March 2024 08:24 UTC](https://forum.confluent.io/t/what-is-the-limit-on-heap-memory-state-store-can-use/10425/2 "2024-03-25T08:24:28Z")

</div>

Are you talking about the JVM heap usage increasing? Assuming you are using RocksDB state stores, the main thing that should influence on-heap memory usage are record caches. You can change the config `StreamsConfig.STATESTORE_CACHE_MAX_BYTES_CONFIG` to reduce on-heap caches.

There are also some other caches in the consumer / producer etc. that may influence the heap memory consumption. Checkout [Kafka Streams Memory Management for Confluent Platform | Confluent Documentation](https://docs.confluent.io/platform/current/streams/developer-guide/memory-mgmt.html) for more information.

---

<div class="post-metadata">

### Author: ![shrenikjain](https://avatars.discourse-cdn.com/v4/letter/s/bb73d2/32.png) [@shrenikjain](https://forum.confluent.io/u/shrenikjain)
#### Post date: [26 March 2024 12:50 UTC](https://forum.confluent.io/t/what-is-the-limit-on-heap-memory-state-store-can-use/10425/3 "2024-03-26T12:50:38Z")

</div>

Thanks for the reply @lbrutschy

But I am creating state store with caching disabled

StoreBuilder\<KeyValueStore\<String, Object\>\> alarmStore = Stores.keyValueStoreBuilder(Stores.persistentKeyValueStore(Constants.ALARM\_STORE), Serdes.String(), Serdes.serdeFrom(serializer, deserializer)).withCachingDisabled();

But still the JVM memory usage increases with the size of state store even if the caching is disabled

2024-03-26 04:29:07,611 CDT INFO [main] StreamsConfig logAll - StreamsConfig values:  
application.id = correlator\_streams  
application.server =  
bootstrap.servers = [127.0.0.1:9092]  
buffered.records.per.partition = 5000  
cache.max.bytes.buffering = 20971520  
client.id =  
commit.interval.ms = 100  
connections.max.idle.ms = 540000  
default.deserialization.exception.handler = class org.apache.kafka.streams.errors.LogAndContinueExceptionHandler  
default.key.serde = class org.apache.kafka.common.serialization.Serdes$StringSerde  
default.production.exception.handler = class org.apache.kafka.streams.errors.DefaultProductionExceptionHandler  
default.timestamp.extractor = class org.apache.kafka.streams.processor.UsePreviousTimeOnInvalidTimestamp  
default.value.serde = class io.confluent.kafka.streams.serdes.avro.GenericAvroSerde  
max.task.idle.ms = 0  
metadata.max.age.ms = 300000  
metric.reporters =   
metrics.num.samples = 2  
metrics.recording.level = INFO  
metrics.sample.window.ms = 30000  
num.standby.replicas = 0  
num.stream.threads = 1  
partition.grouper = class org.apache.kafka.streams.processor.DefaultPartitionGrouper  
poll.ms = 100  
processing.guarantee = exactly\_once  
receive.buffer.bytes = 32768  
reconnect.backoff.max.ms = 1000  
reconnect.backoff.ms = 50  
replication.factor = 1  
request.timeout.ms = 40000  
retries = 0  
retry.backoff.ms = 100  
rocksdb.config.setter = null  
security.protocol = PLAINTEXT  
send.buffer.bytes = 131072  
state.cleanup.delay.ms = 600000  
state.dir = data/correlator/  
topology.optimization = none  
upgrade.from = null  
windowstore.changelog.additional.retention.ms = 86400000

I am using 2.3.0 version of kafka streams library.

Please help here

Thanks  
Shrenik

---

<div class="post-metadata">

### Author: ![lbrutschy](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/lbrutschy/32/2371_2.png) [@lbrutschy](https://forum.confluent.io/u/lbrutschy)
#### Post date: [26 March 2024 13:48 UTC](https://forum.confluent.io/t/what-is-the-limit-on-heap-memory-state-store-can-use/10425/4 "2024-03-26T13:48:00Z")

</div>

- how are you measuring the heap consumption?
- why are you using 2.3.0 which is very old?
- have you tried taking a heap dump and seeing which data structure has all the data?
