SketchUp / sketchup-live-c-api

Examples demonstrating how to use the SketchUp Live C API
MIT License
22 stars 4 forks source link

Q: re, Example does not release model reference #2

Open DanRathbun opened 4 years ago

DanRathbun commented 4 years ago

In the "Using SketchUp Live C API" example ... https://github.com/SketchUp/sketchup-live-c-api/blob/master/docs/using-live-c-api.md#example

The ruby_num_faces function does not release it's reference to the "live" model.

The primer page for standalone C API use has an example comment that says to always release the model reference, viz:

  // Must release the model or there will be memory leaks
  SUModelRelease(&model);

Q: Is releasing the model reference not needed for the "live" C API use ?

Q: What other differences are there from what is described in the standalone use primer section ... Memory Management in the SketchUp C API ?

thomthom commented 4 years ago

Q: Is releasing the model reference not needed for the "live" C API use ?

No, the model reference should not be released because the model is owned by SketchUp. In standalone API usage you need to do The SUCreate* function mention you need to release the model you create with them - because you will be owning them.

SUApplicationGetActiveModel doesn't mention anything about ownership, we can add a note about that in its documentation to make it clear that the application owns the model returned.

Q: What other differences are there from what is described in the standalone use primer section ... Memory Management in the SketchUp C API ?

None really, you are only supposed to release the objects you own.

DanRathbun commented 4 years ago

Add to docs or create FAQ page, whatever is best.