diff --git a/mex/sources/k_order_perturbation/k_ord_dynare.cpp b/mex/sources/k_order_perturbation/k_ord_dynare.cpp
index 54bb972f573fc5c155ca0046427e30ad6e9a6ecc..10e34651cd2d90c9f5632621539d049aff98decb 100644
--- a/mex/sources/k_order_perturbation/k_ord_dynare.cpp
+++ b/mex/sources/k_order_perturbation/k_ord_dynare.cpp
@@ -93,6 +93,8 @@ KordpDynare::~KordpDynare()
     delete dsnl;
   if (denl)
     delete denl;
+  if (JacobianIndices)
+      delete JacobianIndices;
 }
 
 /** This clears the container of model derivatives and initializes it
@@ -180,6 +182,7 @@ KordpDynare::calcDerivatives(const Vector &yy, const Vector &xx) throw (DynareEx
     populateDerivativesContainer(g3, 3, JacobianIndices);
     delete g3;
     }
+  delete llxYYp;
 }
 
 void