accumulating thread count after calling mex file multiple times

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 件のコメント

Jan
Jan 2017 年 5 月 9 日
Without seeing the relevant part of the code, it is impossible to guess, what happens.

サインインしてコメントする。

回答 (1 件)

Chris van der Togt
Chris van der Togt 2017 年 5 月 10 日
編集済み: Chris van der Togt 2017 年 5 月 12 日

0 投票

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;

カテゴリ

ヘルプ センター および File ExchangeWrite C Functions Callable from MATLAB (MEX Files) についてさらに検索

製品

質問済み:

2017 年 5 月 9 日

編集済み:

2017 年 5 月 12 日

Community Treasure Hunt

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

Start Hunting!

Translated by