diff --git a/changelog/5529.bugfix.rst b/changelog/5529.bugfix.rst new file mode 100644 index 000000000000..33cdcf6f3073 --- /dev/null +++ b/changelog/5529.bugfix.rst @@ -0,0 +1 @@ +Fix memory leak problem on increasing number of calls to ``/model/parse`` endpoint. \ No newline at end of file diff --git a/rasa/utils/tensorflow/models.py b/rasa/utils/tensorflow/models.py index d4fa4f63e880..76a34fe94cf0 100644 --- a/rasa/utils/tensorflow/models.py +++ b/rasa/utils/tensorflow/models.py @@ -206,8 +206,8 @@ def predict(self, predict_data: RasaModelData) -> Dict[Text, tf.Tensor]: logger.debug("There is no tensorflow prediction graph.") self.build_for_predict(predict_data) - predict_dataset = predict_data.as_tf_dataset(batch_size=1) - batch_in = next(iter(predict_dataset)) + # Prepare a single batch of size 1 + batch_in = predict_data.prepare_batch(start=0, end=1) self._training = False # needed for eager mode return self._predict_function(batch_in)