# Memory accumulation on train and reload agent with updated models

**URL:** <https://forum.rasa.com/t/memory-accumulation-on-train-and-reload-agent-with-updated-models/22534>\
**Category:** Rasa Open Source\
**Created:** [December 17, 2019, 5:57am UTC](https://forum.rasa.com/t/memory-accumulation-on-train-and-reload-agent-with-updated-models/22534 "2019-12-17T05:57:24Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ksoneji](https://avatars.discourse-cdn.com/v4/letter/k/c57346/32.png) [@ksoneji](https://forum.rasa.com/u/ksoneji)\
**Post date:** [December 17, 2019, 5:57am UTC](https://forum.rasa.com/t/memory-accumulation-on-train-and-reload-agent-with-updated-models/22534/1 "2019-12-17T05:57:24Z")

</div>

We are currently on Rasa - 1.3.2 version. We have few concerns related to the memory consumption by Rasa in the context of the way we use it.

**Use case**

We have a user interface which allows the user to define utterances/dialog flow etc. After changes, we allow the user to publish the changes which will update the models on the Rasa instance that is already running and serving requests. On publish, we run APIs to train the models and reload the agent with a new Interpreter instance.

**We observed that the memory keeps on accumulating each time**

- We try to train the models on the fly
- Reload the agent on the fly i.e. Recreate the Agent with the updated models.

**Note:** we spawn a new thread each time we try to train and reload the models.

**NLU Pipeline Configuration**

pipeline:

- name: “WhitespaceTokenizer”

intent\_split\_symbol: “\_”

intent\_tokenization\_flag: true

- name: “RegexFeaturizer”

- name: “CRFEntityExtractor”

- name: “EntitySynonymMapper”

- name: “CountVectorsFeaturizer”

- name: “EmbeddingIntentClassifier”

- name: DucklingHTTPExtractor

dimensions: [“time”, “number”, “email”]

locale: “en\_US”

timezone: “UTC”

**Dialog Policy Configurations**

1. {“name”: “KerasPolicy”,“priority”:1,“epochs”: 300,“batch\_size”: 10,“validation\_split”: 0.2,“featurizer”: [{“name”: “MaxHistoryTrackerFeaturizer”,“max\_history”: 5,“state\_featurizer”: [{“name”: “BinarySingleStateFeaturizer”}]}]}

2. (“name”: “AugmentedMemoizationPolicy”,“priority”:2,“max\_history”: 6}

3. {“name”:“FallbackPolicy”,“priority”:3,“nlu\_threshold”:0.3,“core\_threshold”:0.3,“ambiguity\_threshold”:0,“fallback\_action\_name”:“action\_default\_fallback”}

4. {“name”:“FormPolicy”,“priority”:4}

5. {“name”:“MappingPolicy”,“priority”:5}

Any help/inputs/suggestions on how to address the memory issue is appreciated.

---

<div class="post-metadata">

**Author:** ![Ghostvv](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/ghostvv/32/211_2.png) [@Ghostvv](https://forum.rasa.com/u/Ghostvv)\
**Post date:** [December 17, 2019, 9:23am UTC](https://forum.rasa.com/t/memory-accumulation-on-train-and-reload-agent-with-updated-models/22534/2 "2019-12-17T09:23:18Z")

</div>

we’re planning to release an update 1.6 where memory consumption of nlu models is drastically reduced

---

<div class="post-metadata">

**Author:** ![kishoresurisetty](https://avatars.discourse-cdn.com/v4/letter/k/58f4c7/32.png) [@kishoresurisetty](https://forum.rasa.com/u/kishoresurisetty)\
**Post date:** [December 17, 2019, 9:59am UTC](https://forum.rasa.com/t/memory-accumulation-on-train-and-reload-agent-with-updated-models/22534/3 "2019-12-17T09:59:14Z")

</div>

@Ghostvv - Thanks for the prompt reply. May I know when 1.6 will be released?

Also, we have observed the memory accumulation while building core models as well. In fact, core modes generation has more accumulation compared to nlu models and it does not get release after the model generation. Any insights on this?

---

<div class="post-metadata">

**Author:** ![Ghostvv](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/ghostvv/32/211_2.png) [@Ghostvv](https://forum.rasa.com/u/Ghostvv)\
**Post date:** [December 17, 2019, 10:02am UTC](https://forum.rasa.com/t/memory-accumulation-on-train-and-reload-agent-with-updated-models/22534/4 "2019-12-17T10:02:50Z")

</div>

what do you mean by memory accumulation?

---

<div class="post-metadata">

**Author:** ![Ghostvv](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/ghostvv/32/211_2.png) [@Ghostvv](https://forum.rasa.com/u/Ghostvv)\
**Post date:** [December 17, 2019, 10:12am UTC](https://forum.rasa.com/t/memory-accumulation-on-train-and-reload-agent-with-updated-models/22534/5 "2019-12-17T10:12:43Z")

</div>

`1.6` is planned for Wednesday, 18.12.2019

---

<div class="post-metadata">

**Author:** ![ksoneji](https://avatars.discourse-cdn.com/v4/letter/k/c57346/32.png) [@ksoneji](https://forum.rasa.com/u/ksoneji)\
**Post date:** [December 18, 2019, 5:25am UTC](https://forum.rasa.com/t/memory-accumulation-on-train-and-reload-agent-with-updated-models/22534/6 "2019-12-18T05:25:24Z")

</div>

Thanks for the update !

---

<div class="post-metadata">

**Author:** ![kishoresurisetty](https://avatars.discourse-cdn.com/v4/letter/k/58f4c7/32.png) [@kishoresurisetty](https://forum.rasa.com/u/kishoresurisetty)\
**Post date:** [December 18, 2019, 5:30am UTC](https://forum.rasa.com/t/memory-accumulation-on-train-and-reload-agent-with-updated-models/22534/7 "2019-12-18T05:30:20Z")

</div>

When the Core models are built, the memory gets occupied and does not get released after the models are generated. As we keep generating the models one after the other memory gets occupied and does not get released.

As @ksoneji mentioned in the original post, we have observed the same behavior when the agent is reloaded on the fly (i.e. Recreate the Agent with new Interpreter instance) with the updated models

---

<div class="post-metadata">

**Author:** ![tmbo](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/tmbo/32/19_2.png) [@tmbo](https://forum.rasa.com/u/tmbo)\
**Post date:** [December 18, 2019, 10:52am UTC](https://forum.rasa.com/t/memory-accumulation-on-train-and-reload-agent-with-updated-models/22534/8 "2019-12-18T10:52:38Z")

</div>

trained policies keep a reference to the training data they got trained with. you could try persisting the agent and loading it afterwards
