diff --git a/fdelmodc/boundaries.c b/fdelmodc/boundaries.c
index 965d026fa447848b452762907a39179827fa5477..cbceb20ebd174dcdb3dd2504f8779da54a616617 100644
--- a/fdelmodc/boundaries.c
+++ b/fdelmodc/boundaries.c
@@ -1113,6 +1113,17 @@ tzz[ix*n1+iz], txz[ix*n1+iz], txx[ix*n1+iz], lam[ix*n1+iz], l2m[ix*n1+iz]);
 
 	}
 
+    if ( (npml != 0) && (itime==mod.nt-1) && pml) {
+#pragma omp master
+{
+		if (allocated) {
+            free(Vxpml);
+        	free(Vzpml);
+        	free(sigmu);
+        	free(RA);
+		}
+}
+	}
 
 	return 0;
 } 
@@ -1648,9 +1659,19 @@ int boundariesV(modPar mod, bndPar bnd, float *vx, float *vz, float *tzz, float
 				}
 			}
 		}
-
-		
 	}
 	
+    if ( (npml != 0) && (itime==mod.nt-1) && pml) {
+#pragma omp master
+{
+		if (allocated) {
+            free(Pxpml);
+        	free(Pzpml);
+        	free(sigmu);
+        	free(RA);
+		}
+}
+	}
+
 	return 0;
 }