Merge pull request #795 from davidgyu/endCapStorageFix

Fixed residual memory consumed by end cap stencils
This commit is contained in:
Takahito Tejima 2016-03-23 13:44:25 -07:00
commit a4f4357110
2 changed files with 21 additions and 2 deletions

View File

@ -1304,14 +1304,14 @@ PatchTableFactory::populateAdaptivePatches(
// finalize end patches
if (localPointStencils and localPointStencils->GetNumStencils() > 0) {
localPointStencils->generateOffsets();
localPointStencils->finalize();
} else {
delete localPointStencils;
localPointStencils = NULL;
}
if (localPointVaryingStencils and localPointVaryingStencils->GetNumStencils() > 0) {
localPointVaryingStencils->generateOffsets();
localPointVaryingStencils->finalize();
} else {
delete localPointVaryingStencils;
localPointVaryingStencils = NULL;

View File

@ -208,6 +208,12 @@ protected:
// Reserves the table arrays (factory helper)
void reserve(int nstencils, int nelems);
// Reallocates the table arrays to remove excess capacity (factory helper)
void shrinkToFit();
// Performs any final operations on internal tables (factory helper)
void finalize();
protected:
StencilTable() : _numControlVertices(0) {}
StencilTable(int numControlVerts)
@ -419,6 +425,19 @@ StencilTable::reserve(int nstencils, int nelems) {
_weights.reserve(nelems);
}
inline void
StencilTable::shrinkToFit() {
std::vector<int>(_sizes).swap(_sizes);
std::vector<Index>(_indices).swap(_indices);
std::vector<float>(_weights).swap(_weights);
}
inline void
StencilTable::finalize() {
shrinkToFit();
generateOffsets();
}
// Returns a Stencil at index i in the table
inline Stencil
StencilTable::GetStencil(Index i) const {