title: Is it possible return cell array that contains one instance in several cells?
body: <p>I write some mex function and have to return huge array of strings. </p>
  
  <p>I do this as following:</p>
  
  <pre><code>  mxArray * array = mxCreateCellMatrix(ARRAY_LEN, 1);
    for (size_t k = 0; k &lt; ARRAY_LEN; ++ k) {
        mxArray *str = mxCreateString("Hello");
        mxSetCell(array, k, str);
    }
    prhs[0] = array;
  </code></pre>
  
  <p>However, since the string has always same value, I would like to create only one instance of it.
  like </p>
  
  <pre><code>  mxArray * array = mxCreateCellMatrix(ARRAY_LEN, 1);
    mxArray *str = mxCreateString("Hello");
  
    for (size_t k = 0; k &lt; ARRAY_LEN; ++ k) {
        mxSetCell(array, k, str);
    }
    prhs[0] = array;
  </code></pre>
  
  <p>Does it possible? How the garbage collector knows to release it?
  Thank you.</p>