Passing data between JS and C++ without a copy?


  • We have some code in a C++ WinMD component dll that creates an array of data and sends it to our JavaScript UI as an async update.  This code needs to be fairly performant (which is why we wrote that part in C++) so we are trying to investigate ways to improve the performance.  I am wondering, for classes that cross over the ABI between languages, does a copy always happen of the sealed class that is passed?  Take, for example, the following snippet from my C++ WinMD component dll:

    namespace Utils
       public ref class ScreenUpdate sealed
          ScreenUpdate(const Platform::Array<unsigned char>^ bufIn, int xIn);
          Platform::Array<unsigned char>^ GetBuffer();
          int GetX();
          const Platform::Array<unsigned char>^ buffer;
          int x;
       public ref class Session sealed
          Windows::Foundation::IAsyncActionWithProgress<ScreenUpdate^>^ StartSession(Platform::String^ target);

    When my JavaScript code is receiving these progress updates of ScreenUpdate^ after it calls StartSession, is this class being copied into my JavaScript code or are they all referencing the same object and using refcounts?

    Monday, May 20, 2013 3:30 PM

All replies

  • From what I understood from last years build// this is not copied, just referenced.
    Wednesday, May 22, 2013 10:12 AM