locked
Who's responsible for destroying SurfaceImageSource objects?

    Question

  • In the case of a C# app that uses C++ interop, do XAML objects created in C++ using "ref new" need to be explicitly destroyed using "delete"? Or, does garbage collection on the C# side know to destroy those objects?

    In particular, I'm wondering how SurfaceImageSource objects get destroyed.

    Thursday, September 13, 2012 7:45 PM

Answers

  • All 'ref new' objects are reference counted so they are cleaned up automatically. You do not explicitly 'delete' them.
    • Marked as answer by Bob Flora Friday, September 14, 2012 12:32 AM
    Thursday, September 13, 2012 8:05 PM

All replies

  • All 'ref new' objects are reference counted so they are cleaned up automatically. You do not explicitly 'delete' them.
    • Marked as answer by Bob Flora Friday, September 14, 2012 12:32 AM
    Thursday, September 13, 2012 8:05 PM
  • All 'ref new' objects are reference counted so they are cleaned up automatically. You do not explicitly 'delete' them.
    So, when I'm done with a "ref new" object I just need to be sure to assign "nullptr" to it to release it, and I'm done. Is that correct?
    Thursday, September 13, 2012 11:23 PM
  • All 'ref new' objects are reference counted so they are cleaned up automatically. You do not explicitly 'delete' them.

    So, when I'm done with a "ref new" object I just need to be sure to assign "nullptr" to it to release it, and I'm done. Is that correct?

    Never mind. I found that objects created with "ref new" are automatically destroyed when they go out of scope. A "nullptr" assignment is not necessary unless you want to assign it to a variable holding a "ref new" object so you can reuse the variable for another "ref new" object.

    Thanks, Chuck!

    Friday, September 14, 2012 12:32 AM