[cig-commits] r21786 - in short/3D/PyLith/trunk: libsrc/pylith/faults libsrc/pylith/topology unittests/libtests/faults

brad at geodynamics.org brad at geodynamics.org
Tue Apr 9 15:24:17 PDT 2013


Author: brad
Date: 2013-04-09 15:24:17 -0700 (Tue, 09 Apr 2013)
New Revision: 21786

Modified:
   short/3D/PyLith/trunk/libsrc/pylith/faults/CohesiveTopology.cc
   short/3D/PyLith/trunk/libsrc/pylith/topology/Field.cc
   short/3D/PyLith/trunk/unittests/libtests/faults/TestEqKinSrc.cc
   short/3D/PyLith/trunk/unittests/libtests/faults/TestSlipFn.cc
   short/3D/PyLith/trunk/unittests/libtests/faults/TestTractPerturbation.cc
   short/3D/PyLith/trunk/unittests/libtests/faults/test_faults.cc
Log:
Fixed some memory leaks.

Modified: short/3D/PyLith/trunk/libsrc/pylith/faults/CohesiveTopology.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/faults/CohesiveTopology.cc	2013-04-09 22:06:39 UTC (rev 21785)
+++ short/3D/PyLith/trunk/libsrc/pylith/faults/CohesiveTopology.cc	2013-04-09 22:24:17 UTC (rev 21786)
@@ -719,8 +719,10 @@
     }
     err = DMPlexRestoreTransitiveClosure(faultDMMesh, faceDM, PETSC_TRUE, &closureSize, &faceConeDM);CHECK_PETSC_ERROR(err);
   } // for over fault faces
+  delete f_iter; f_iter = NULL;
   if (sV2) {
-    delete sV2; delete cV2;
+    delete sV2; sV2 = NULL;
+    delete cV2; cV2 = NULL;
   }
   // This completes the set of cells scheduled to be replaced
   // TODO: Convert to DMPlex

Modified: short/3D/PyLith/trunk/libsrc/pylith/topology/Field.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/topology/Field.cc	2013-04-09 22:06:39 UTC (rev 21785)
+++ short/3D/PyLith/trunk/libsrc/pylith/topology/Field.cc	2013-04-09 22:24:17 UTC (rev 21786)
@@ -960,11 +960,12 @@
   if (sinfo.scatter) {
     assert(sinfo.scatterVec);
     assert(sinfo.vector);
-    return;
+    PYLITH_METHOD_END;
   } // if
 
   PetscInt localSize, globalSize;
 
+
   err = PetscObjectReference((PetscObject) _dm);CHECK_PETSC_ERROR(err);
   err = PetscObjectReference((PetscObject) _globalVec);CHECK_PETSC_ERROR(err);
   err = PetscObjectSetName((PetscObject) _globalVec, _metadata["default"].label.c_str());CHECK_PETSC_ERROR(err);
@@ -972,6 +973,9 @@
   err = VecGetSize(_globalVec, &globalSize);CHECK_PETSC_ERROR(err);
   //assert(order->getLocalSize()  == localSize);
   //assert(order->getGlobalSize() == globalSize);
+
+  err = DMDestroy(&sinfo.dm);CHECK_PETSC_ERROR(err);
+  err = VecDestroy(&sinfo.vector);CHECK_PETSC_ERROR(err);
   sinfo.vector = _globalVec;
   sinfo.dm     = _dm;
   
@@ -1004,7 +1008,7 @@
   if (sinfo.scatter) {
     assert(sinfo.scatterVec);
     assert(sinfo.vector);
-    return;
+    PYLITH_METHOD_END;
   } // if
 
   PetscInt localSize, globalSize;
@@ -1054,7 +1058,7 @@
   if (sinfo.scatter) {
     assert(sinfo.scatterVec);
     assert(sinfo.vector);
-    return;
+    PYLITH_METHOD_END;
   } // if
 
   PetscSection section, newSection, gsection;
@@ -1068,6 +1072,7 @@
   err = DMGetPointSF(sinfo.dm, &sf);CHECK_PETSC_ERROR(err);
   err = PetscSectionCreateGlobalSection(section, sf, PETSC_TRUE, &gsection);CHECK_PETSC_ERROR(err);
   err = DMSetDefaultGlobalSection(sinfo.dm, gsection);CHECK_PETSC_ERROR(err);
+  err = PetscSectionDestroy(&gsection);CHECK_PETSC_ERROR(err);
   err = DMCreateGlobalVector(sinfo.dm, &sinfo.vector);CHECK_PETSC_ERROR(err);
   err = PetscObjectSetName((PetscObject) sinfo.vector, _metadata["default"].label.c_str());CHECK_PETSC_ERROR(err);
   PetscInt localSize, globalSize;
@@ -1106,7 +1111,7 @@
   if (sinfo.scatter) {
     assert(sinfo.scatterVec);
     assert(sinfo.vector);
-    return;
+    PYLITH_METHOD_END;
   } // if
 
   PetscDM dm = mesh.dmMesh();assert(dm);

Modified: short/3D/PyLith/trunk/unittests/libtests/faults/TestEqKinSrc.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestEqKinSrc.cc	2013-04-09 22:06:39 UTC (rev 21785)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestEqKinSrc.cc	2013-04-09 22:24:17 UTC (rev 21786)
@@ -203,6 +203,8 @@
                            faultId,
                            firstFaultVertex, firstLagrangeVertex, firstFaultCell,
                            useLagrangeConstraints);
+  err = DMDestroy(&faultBoundaryDM);CHECK_PETSC_ERROR(err);
+
   // Need to copy coordinates from mesh to fault mesh since we are not
   // using create() instead of createParallel().
   _setupFaultCoordinates(mesh, faultMesh);
@@ -294,6 +296,7 @@
   err = VecRestoreArray(coordVec, &coords);CHECK_PETSC_ERROR(err);
   err = VecRestoreArray(fcoordVec, &fcoords);CHECK_PETSC_ERROR(err);
   err = DMSetCoordinatesLocal(faultDMMesh, fcoordVec);CHECK_PETSC_ERROR(err);
+  err = VecDestroy(&fcoordVec);CHECK_PETSC_ERROR(err);
 } // _setupFaultCoordinates
 
 

Modified: short/3D/PyLith/trunk/unittests/libtests/faults/TestSlipFn.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestSlipFn.cc	2013-04-09 22:06:39 UTC (rev 21785)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestSlipFn.cc	2013-04-09 22:24:17 UTC (rev 21786)
@@ -62,6 +62,7 @@
     CPPUNIT_ASSERT(!sieveMesh.isNull());
     CohesiveTopology::createFault(faultMesh, faultBoundary, faultBoundaryDM, *mesh, groupField);
     CohesiveTopology::create(mesh, *faultMesh, faultBoundary, faultBoundaryDM, groupField, faultId, firstFaultVertex, firstLagrangeVertex, firstFaultCell, useLagrangeConstraints);
+    err = DMDestroy(&faultBoundaryDM);CHECK_PETSC_ERROR(err);
   } // Create mesh
 
   { // Need to copy coordinates from mesh to fault mesh since we are not
@@ -111,6 +112,7 @@
     err = VecRestoreArray(coordVec, &coords);CHECK_PETSC_ERROR(err);
     err = VecRestoreArray(fcoordVec, &fcoords);CHECK_PETSC_ERROR(err);
     err = DMSetCoordinatesLocal(faultDMMesh, fcoordVec);CHECK_PETSC_ERROR(err);
+    err = VecDestroy(&fcoordVec);CHECK_PETSC_ERROR(err);
   } // Copy coordiantes
 
 

Modified: short/3D/PyLith/trunk/unittests/libtests/faults/TestTractPerturbation.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestTractPerturbation.cc	2013-04-09 22:06:39 UTC (rev 21785)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestTractPerturbation.cc	2013-04-09 22:24:17 UTC (rev 21786)
@@ -373,6 +373,8 @@
                            faultId,
                            firstFaultVertex, firstLagrangeVertex, firstFaultCell,
                            useLagrangeConstraints);
+  err = DMDestroy(&faultBoundaryDM);CHECK_PETSC_ERROR(err);
+
   // Need to copy coordinates from mesh to fault mesh since we are
   // using create() instead of createParallel().
   _setupFaultCoordinates(mesh, faultMesh);
@@ -479,6 +481,7 @@
   err = VecRestoreArray(coordVec, &coords);CHECK_PETSC_ERROR(err);
   err = VecRestoreArray(fcoordVec, &fcoords);CHECK_PETSC_ERROR(err);
   err = DMSetCoordinatesLocal(faultDMMesh, fcoordVec);CHECK_PETSC_ERROR(err);
+  err = VecDestroy(&fcoordVec);CHECK_PETSC_ERROR(err);
 } // _setupFaultCoordinates
 
 

Modified: short/3D/PyLith/trunk/unittests/libtests/faults/test_faults.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/test_faults.cc	2013-04-09 22:06:39 UTC (rev 21785)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/test_faults.cc	2013-04-09 22:24:17 UTC (rev 21786)
@@ -30,7 +30,7 @@
 
 #include <stdlib.h> // USES abort()
 
-//#define MALLOC_DUMP
+#define MALLOC_DUMP
 
 int
 main(int argc,



More information about the CIG-COMMITS mailing list