Hi,
An other memory leak problem is found while testing the SketchUp 2016 SDK in ARCHICAD on Mac OS X. It seems SDK does not free all objects when we give a degenerate triangle to it (degenerate means collinear points).
A minimal code sample, with which this problem can be reproduced:
// Create an empty model
SUModelRef skpModel = SU_INVALID;
SUModelCreate (&skpModel);
SUEntitiesRef modelEntities = SU_INVALID;
SUModelGetEntities (skpModel, &modelEntities);
// Use a geometry input object
SUGeometryInputRef geometry = SU_INVALID;
SUGeometryInputCreate (&geometry);
// Add vertices (collinear points)
{
std::vector<SUPoint3D> vertices (3);
vertices[0].x = -9.06436;
vertices[0].y = -2.9534;
vertices[0].z = 2.35;
vertices[1].x = -9.86436;
vertices[1].y = -2.9534;
vertices[1].z = 2.35;
vertices[2].x = -9.88936;
vertices[2].y = -2.9534;
vertices[2].z = 2.35;
SUGeometryInputSetVertices (geometry, 3, vertices.data ());
}
// Add face with one outer loop
SULoopInputRef loop = SU_INVALID;
SULoopInputCreate (&loop);
for (size_t vertIdx = 0; vertIdx < 3; ++vertIdx) {
SULoopInputAddVertexIndex (loop, vertIdx);
}
SUGeometryInputAddFace (geometry, &loop, nullptr);
// Fill entities with geometry
SUEntitiesFill (modelEntities, geometry, true);
SUGeometryInputRelease (&geometry);
SUModelSaveToFileWithVersion (skpModel, "filePath.skp", SUModelVersion_SU2016);
SUModelRelease (&skpModel);
Our memory detection shows more places of leaks in this case:
1)
…
SUEntitiesFill
COctree::StorePoint(atlast::geometry::CPoint3d const&)
COctree::FindVertexInTolerance(COctVertex*, bool)
operator new(unsigned long)
…
…
SUEntitiesFill
COctree::StorePoint(atlast::geometry::CPoint3d const&)
operator new(unsigned long)
…
…
SUEntitiesFill
GeometryHelper::CreateEdgesAndCurves(CVertex**, sketchup::slapi::LoopInput const&, scoped_array<CEdge*>, scoped_arrayatlast::geometry::CPoint3d, unsigned long*)
operator new(unsigned long)
…
…
SUEntitiesFill
GeometryHelper::CreateEdgesAndCurves(CVertex**, sketchup::slapi::LoopInput const&, scoped_array<CEdge*>, scoped_arrayatlast::geometry::CPoint3d, unsigned long*)
CEdge::CEdge(CVertex*, CVertex*, bool)
CVertex::AddEdge(CEdge*, bool)
CShortArray<CEdge*>::SetMaxSize(unsigned short)
operator new(unsigned long)
…
We use the workaround to check the triangles before pass to the SDK, but I think it would be better if the SDK could handle this kind of triangles itself.
Thanks,
Tamás Zolnai