Memory leak in SUFaceCreateSimple ()


While integrating SketchUp 2016 SDK in our ARCHICAD software we found that if a face is created using SUFaceCreateSimple () method, memory leak occurs in the SDK. This problem detected on Mac OS X.

A minimal code sample:

std::vector<SUPoint3D> vertices (3);
vertices[0].x = -9.06436;
vertices[0].y = -2.80;
vertices[0].z = 2.35;
vertices[1].x = -9.86436;
vertices[1].y = -2.90;
vertices[1].z = 2.35;
vertices[2].x = -9.88936;
vertices[2].y = -2.90;
vertices[2].z = 2.35;
SUFaceRef face = SU_INVALID;
SUFaceCreateSimple (&face, (), vertices.size ());
SUFaceRelease (&face);

The place of the detected leak:

FaceCreate(SUPoint3D const*, sketchup::slapi::LoopInput const&, SUFaceRef*)
CreateEdgesAndCurves(SUPoint3D const*, sketchup::slapi::LoopInput const&, scoped_array<CEdge*>, scoped_arrayatlast::geometry::CPoint3d, unsigned long*)
operator new(unsigned long)

We tested it with more test cases and it seems this leak is not related to the specific vertices.
As a workaround we used the other way of creating geometry (SUGeometryInput), but would be good to have this SUFaceCreateSimple () work properly.

Tamás Zolnai

Thank you for this report. (Concerning that you seem to have found a few already!)

By the way, the SU_FaceCreate is currently bugged and doesn’t create models which doesn’t merge edges and vertices as SU expects them to be. So until that is addressed you want to use SU_GeometryInput in any case.

Logged internally as SU-33887.