accumulating thread count after calling mex file multiple times

1 vue (au cours des 30 derniers jours)
Chris van der Togt
Chris van der Togt le 9 Mai 2017
I have written a mex function that opens a W32 window as a child to a matlab window. And a second function that closes this window.
After calling these functions repetitively (20+) without errors, matlab becomes unresponsive after 5 to 10 minutes. Even if i call drawnow in between the other calls. The only thing I notice is, that after each call to my mex functions the number of threads associated with matlab increases (>250).
I am not creating threads in my mex function and after creating a window in the first call, I reuse the handle to the window.
Question, why does matlab freeze after some time , and why is the number of threads increasing.
regards,
Chris
  1 commentaire
Jan
Jan le 9 Mai 2017
Without seeing the relevant part of the code, it is impossible to guess, what happens.

Connectez-vous pour commenter.

Réponses (1)

Chris van der Togt
Chris van der Togt le 10 Mai 2017
Modifié(e) : Chris van der Togt le 12 Mai 2017
I've not put any code because it would have been too much, but I think I have solved the issue.
The thing is that in addition to creating a w32 window (which is no problem at all), I was using this as a directx render target.
IN the initializing call of the directX device I obtained a pointer to the back buffer, but forgot to release the pointer. This leads to a silent increase of thread use in matlab, which ultimately leads it to hang.
ID3D11Texture2D* pBackBuffer = NULL;
hr = g_pSwapChain->GetBuffer( 0, __uuidof( ID3D11Texture2D ), ( LPVOID* )&pBackBuffer );
if( FAILED( hr ) )
return hr;
hr = g_pd3dDevice->CreateRenderTargetView( pBackBuffer, NULL, &g_pRenderTargetView );
pBackBuffer->Release(); // * *critical part I forgot.**
if( FAILED( hr ) )
return hr;

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by