How can I free the memory of a c++ safearray in c# -


i need pass data c++ dll c# environment. therefore use 2d safearray of doubles.

this function passes data c++ c#:

void getindividualexposures(safearray*& data) {     safearraybound bounds[2];     bounds[0].llbound = 0;     bounds[0].celements = 10;     bounds[1].llbound = 0;     bounds[1].celements = 20;      long l_dimensions[2];     int index = 0;      data = safearraycreate(vt_r8, 2, bounds);     double **pvals;      hresult hr = safearrayaccessdata(data, (void**)&pvals);     if (succeeded(hr))     {         (ulong = 0; < bounds[0].celements; i++)         {             (ulong j = 0; j < bounds[1].celements; j++)             {                 l_dimensions[0] = i;                 l_dimensions[1] = j;                 safearrayputelement(data, l_dimensions, &data_source[i][j]);             }         }         safearrayunaccessdata(data);     } } 

this works, fine, data available needed in c# environment. memory leak. tried use second c++ function free memory:

void deallocateexternal(safearray*& data) {     safearraydestroy(data);     data = null; } 

but has no effect. did wrong? there possibility free memory of safearray after use in c#? or how can this?


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -