Is there memory leak in FEniCS and how to fix it?

Thank you for the quick answer. You were right, when I assemble the matrix and vector outside the loop, there is no memory leak.

I guess the problem is that the new matrix and vector are created in each new iteration and the memory is not released after the use. Is this correct?

This solves the problem with Poisson equation with constant source term. However, what should I do when the source term changes with each iteration i.e. when I have time dependent problem?