[cig-commits] [commit] knepley/upgrade-petsc-interface: Fix memory leak in visitor for subfield. (edfb2b6)
cig_noreply at geodynamics.org
cig_noreply at geodynamics.org
Fri Jan 24 12:27:44 PST 2014
Repository : ssh://geoshell/pylith
On branch : knepley/upgrade-petsc-interface
Link : https://github.com/geodynamics/pylith/compare/fa8f90cf8f440fcb256e83f31f76c64a0616a100...edfb2b64844b53495d10786111ea7ed92696de4a
>---------------------------------------------------------------
commit edfb2b64844b53495d10786111ea7ed92696de4a
Author: Brad Aagaard <baagaard at usgs.gov>
Date: Fri Jan 24 12:27:42 2014 -0800
Fix memory leak in visitor for subfield.
Getting section for subfield increments reference count. Switch to
incrementing reference count for section for field case as well. Destroy
section when done.
>---------------------------------------------------------------
edfb2b64844b53495d10786111ea7ed92696de4a
libsrc/pylith/topology/VisitorMesh.icc | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/libsrc/pylith/topology/VisitorMesh.icc b/libsrc/pylith/topology/VisitorMesh.icc
index 5cfe0d1..40af9ed 100644
--- a/libsrc/pylith/topology/VisitorMesh.icc
+++ b/libsrc/pylith/topology/VisitorMesh.icc
@@ -64,6 +64,7 @@ pylith::topology::VecVisitorMesh::initialize(const Field& field,
if (!subfield) {
_section = fieldSection;
+ err = PetscObjectReference((PetscObject)_section);PYLITH_CHECK_ERROR(err);
} else {
const Field::Metadata fieldMetadata = field.subfieldMetadata(subfield);
assert(fieldMetadata.index >= 0 && fieldMetadata.index < numFields);
@@ -80,11 +81,14 @@ inline
void
pylith::topology::VecVisitorMesh::clear(void)
{ // clear
+ PetscErrorCode err;
+
if (_localVec) {
- PetscErrorCode err = VecRestoreArray(_localVec, &_localArray);PYLITH_CHECK_ERROR(err);assert(!_localArray);
+ err = VecRestoreArray(_localVec, &_localArray);PYLITH_CHECK_ERROR(err);assert(!_localArray);
} // if
- _section = NULL;
+ err = PetscSectionDestroy(&_section);PYLITH_CHECK_ERROR(err);
+
_localVec = NULL;
} // clear
More information about the CIG-COMMITS
mailing list