possible memory leak in RoomCapture sample code


There is a possible memory leak(unreleased memory) in newFillHolesTaskWithMesh and newColorizeTaskWithMesh with STColorizerTextureMapForObject option combination.
To easily reproduce the problem, just modify one line of code in startHoleFillingAndColorizingTasks function in the Roomcapture sample
options:@{kSTColorizerTypeKey: @(STColorizerTextureMapForRoom) }
options:@{kSTColorizerTypeKey: @(STColorizerTextureMapForObject) }

then use Xcode Memory Graph Debugger with “Live Allocations Only” for Malloc Stack logging ( Instruments works also) to capture, save in memgraph file.

there is a 16MB memory leak for every cycle “Start page (Scan/Done)=> Mesh View=>enable Hole Filling=>Back=>Start page”. I usually run 3 or 5 cycles.
I also notice there are leaks for STMesh: 2-node-cycle —> NSMallocBlock—> STMesh

Would you please try to reproduce and help to solve the problem? Right now I have to disable HoleFilling function in our application.

Thanks a lot.


I am going to pass this along to one of our Structure SDK engineers to look more deeply into but my initial thought is that the Room Capture Application is allocating memory to scan a room, thusly using STColorizerTextureMapForObject will use less memory than is allocated due to being specifically made to scan objects and not rooms.


Hi, Anthony:

Our app is actually based on Scanner sample, I port HoleFilling function from RoomCapture to Scanner, got the same behavior. For simplicity (easy for you to reproduce), I choose RoomCapture sample to modify. When you scan with RoomCapture, don’t need move around, just take capture at some 20cm object back and forth for a couple of times, you will see the problem.

Additional info: every time the leak 16MB or 4MB shows up, there is a “std::__1::bad_function_call” item appears in the same memory graph




We appreciate you taking the time to detail the issue you have seen. As stated previously, I have passed the information onto the SDK Team to look more deeply into it.


memory leaks are spotted under Instruments "leaks" tool for original Scanner/RoomCapture sample codes (0.71)