accumulating thread count after calling mex file multiple times

조회 수: 8 (최근 30일)
Chris van der Togt
Chris van der Togt 2017년 5월 9일
편집: Chris van der Togt 2017년 5월 12일
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일
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;

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by