# Memory usage is remaining high after a finished query

**URL:** <https://community.influxdata.com/t/memory-usage-is-remaining-high-after-a-finished-query/21004>\
**Category:** InfluxDB 1\
**Tags:** influxdb\
**Created:** [August 2, 2021, 11:04am UTC](https://community.influxdata.com/t/memory-usage-is-remaining-high-after-a-finished-query/21004 "2021-08-02T11:04:15Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ruke\_Chen](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/ruke_chen/32/7266_2.png) [@Ruke\_Chen](https://community.influxdata.com/u/Ruke_Chen)\
**Post date:** [August 2, 2021, 11:04am UTC](https://community.influxdata.com/t/memory-usage-is-remaining-high-after-a-finished-query/21004/1 "2021-08-02T11:04:15Z")

</div>

Hello All,

We are using InfluxDB v1.8.3 (git: 1.8 [563e6c3](https://github.com/influxdata/influxdb/commit/563e6c3d1a7a2790763c6289501095dbec19244e)) as our time-series database in our startup. I create a github issue [influxd keeps high memory usage · Issue #21965 · influxdata/influxdb · GitHub](https://github.com/influxdata/influxdb/issues/21965), We don’t have any problem for writing data to the database. What we faced is after several queries to the database, our Memory (RAM)usage goes up and never comes down even after the query has finished.

So if we continue to execute a new query to Influxdb, it uses more memory, and at some point, it causes memory and OOM occurs.

---

<div class="post-metadata">

**Author:** ![Anaisdg](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/anaisdg/32/6401_2.png) [@Anaisdg](https://community.influxdata.com/u/Anaisdg)\
**Post date:** [August 3, 2021, 3:49pm UTC](https://community.influxdata.com/t/memory-usage-is-remaining-high-after-a-finished-query/21004/2 "2021-08-03T15:49:24Z")

</div>

Hello @Ruke_Chen,  
Could this be related to your issue?

> [@High memory usage on TSI mode](https://community.influxdata.com/t/high-memory-usage-on-tsi-mode/16521):
>
> We are running a stress test with importing certain amount of history records from scratch using InfluxDB v1.8.3 OSS. The goal of the test is to discover the needed parameters to set and the hardware spec in order to gain the best out of InfluxDB. By switching to TSI mode, we expect to decrease memory usage. Unfortunately, we’re pretty much stuck in the same situation where the memory usage is still high and InfluxDB service was up and down periodically. We’ve tried some ways mentioned in other …

---

<div class="post-metadata">

**Author:** ![Ruke\_Chen](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/ruke_chen/32/7266_2.png) [@Ruke\_Chen](https://community.influxdata.com/u/Ruke_Chen)\
**Post date:** [August 4, 2021, 1:48am UTC](https://community.influxdata.com/t/memory-usage-is-remaining-high-after-a-finished-query/21004/3 "2021-08-04T01:48:49Z")

</div>

Hi @Anaisdg

I had already checked out this topic, and added this configuration GODEBUG=madvdontneed=1 in /etc/default/influxdb, restarted influxd, and did my test on 2021/08/03. The result is the same. Memory usage is remaining high after querying.

Thanks

---

<div class="post-metadata">

**Author:** ![wbaker](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/wbaker/32/7481_2.png) [@wbaker](https://community.influxdata.com/u/wbaker)\
**Post date:** [August 4, 2021, 8:32pm UTC](https://community.influxdata.com/t/memory-usage-is-remaining-high-after-a-finished-query/21004/4 "2021-08-04T20:32:32Z")

</div>

> [@Ruke\_Chen](#):
>
> 1.8.3 (git: 1.8 [563e6c3](https://github.com/influxdata/influxdb/commit/563e6c3d1a7a2790763c6289501095dbec19244e)) as our time-series database in our startup. I create a github issue [influxd keeps high memory usage · Issue #21965 · influxdata/influxdb · GitHub](https://github.com/influxdata/influxdb/issues/21965), We don’t have any problem for writing data to the database. What we faced is after several queries to the database, our Memory (RAM)usage goes up and never comes down even after the query has finished.
> 
> So if we continue to execute a new query to Influxdb, it uses more memory, and at some point, it causes memory and OOM occurs.

@Ruke_Chen - are you running `influxd` in a docker container? I wasn’t 100% sure from your description here or in the issue. We’ve got a few open issues related to memory usage, particularly running docker containers, that we are investigating. It’s not a quick fix, but I appreciate you taking the time to write up such clear instructions on how to reproduce the issue so that we can include it in our investigation!

---

<div class="post-metadata">

**Author:** ![Ruke\_Chen](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/ruke_chen/32/7266_2.png) [@Ruke\_Chen](https://community.influxdata.com/u/Ruke_Chen)\
**Post date:** [August 5, 2021, 1:39am UTC](https://community.influxdata.com/t/memory-usage-is-remaining-high-after-a-finished-query/21004/5 "2021-08-05T01:39:53Z")

</div>

Hi @wbaker ,

Yes. I am running influxd in alpine docker container. ([influxdata-docker/influxdb/1.8/alpine at 0d341f18067c4652dfa8df7dcb24d69bf707363d · influxdata/influxdata-docker · GitHub](https://github.com/influxdata/influxdata-docker/tree/0d341f18067c4652dfa8df7dcb24d69bf707363d/influxdb/1.8/alpine)).  
Within this docker file, we build our own docker image which contains InfluxDB 1.8.3. The difference is we change the index-version to “tsi1”. The detail step is mentioned in [influxd keeps high memory usage · Issue #21965 · influxdata/influxdb · GitHub](https://github.com/influxdata/influxdb/issues/21965). Although I make a simple modification for generating testing data, I think it doesn’t matter. Anyway, if you need further information, please let met know, Thanks

---

<div class="post-metadata">

**Author:** ![Ruke\_Chen](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/ruke_chen/32/7266_2.png) [@Ruke\_Chen](https://community.influxdata.com/u/Ruke_Chen)\
**Post date:** [August 13, 2021, 8:28am UTC](https://community.influxdata.com/t/memory-usage-is-remaining-high-after-a-finished-query/21004/6 "2021-08-13T08:28:20Z")

</div>

Hi,

Any update?

Thanks

---

<div class="post-metadata">

**Author:** ![Ruke\_Chen](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/ruke_chen/32/7266_2.png) [@Ruke\_Chen](https://community.influxdata.com/u/Ruke_Chen)\
**Post date:** [September 2, 2021, 5:45am UTC](https://community.influxdata.com/t/memory-usage-is-remaining-high-after-a-finished-query/21004/7 "2021-09-02T05:45:51Z")

</div>

Hi @Anaisdg and @wbaker

Andy good news?

Thanks

---

<div class="post-metadata">

**Author:** ![wbaker](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/wbaker/32/7481_2.png) [@wbaker](https://community.influxdata.com/u/wbaker)\
**Post date:** [September 2, 2021, 4:45pm UTC](https://community.influxdata.com/t/memory-usage-is-remaining-high-after-a-finished-query/21004/8 "2021-09-02T16:45:37Z")

</div>

@Ruke_Chen - we’re working pretty hard on performance improvements and memory usage is on the radar. I don’t have any other news right now but we definitely haven’t forgotten about it!

---

<div class="post-metadata">

**Author:** ![Ruke\_Chen](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/ruke_chen/32/7266_2.png) [@Ruke\_Chen](https://community.influxdata.com/u/Ruke_Chen)\
**Post date:** [October 5, 2021, 9:50am UTC](https://community.influxdata.com/t/memory-usage-is-remaining-high-after-a-finished-query/21004/9 "2021-10-05T09:50:24Z")

</div>

Hi @wbaker

I use the following command to launch influxd

```auto
env GODEBUG=madvdontneed=1 /usr/bin/influxd

```

The memory usage looks much better. The memory usage of influxd would increase while querying, but after a while the memory usage is decrease.

Thanks
