I tried to use PETSC direct solver (SUPER LU) to solve the system of equations. After a long time effort, the code is working properly and gives some good results. The only issue that came up recently is a bout memory leakage. I found that after iterations RES memory is increasing which leads to the server crash. I tried bunch of cures which I found on the web, but none of them worked. I am using MatDestroy and VecDestroy at the end of PETSC part in the code to free all the allocated memories. This is not helpful. I also tried iterative solvers like Richardson and other direct solver like spooles and the same problem occurred. I would appreciate if you could help me in this regard.