Community
cancel
Showing results for 
Search instead for 
Did you mean: 
lixiang_h_
Beginner
95 Views

Intel® Quick Sync Video H.264 Encoder MFT Memory Leak

    I split the code from OBS studio and just used to encode ARGB to H264 using the Intel® Quick Sync Video H.264 Encoder MFT. But the basic procedures for each Create/Destory has a memory leak, and I find the memory leak that is the first three frame sendto ProcessInput() and inside call  MFPlat!MFCreateMemoryBuffer . how do I release it ?

 

I use UMDH contrast before and after,  the follow:  


+ 1250000 ( 1250000 -      0)      2 allocs BackTraceFE719991
+       2 (      2 -      0) BackTraceFE719991 allocations

 ntdll!RtlpCallInterceptRoutine+0000003F
 ntdll!RtlpAllocateHeapInternal+00001142
 msvcrt!malloc+00000070
 MFPlat!MFTraceFuncEnter+00000257
 MFPlat!MFCreateMemoryBuffer+0000054C
 mfx_mft_h264ve_64!DllGetClassObject+0003FC57
 mfx_mft_h264ve_64!DllGetClassObject+00041155
 mfx_mft_h264ve_64!DllGetClassObject+00040F01
 mfx_mft_h264ve_64!DllGetClassObject+000409EA
 mfx_mft_h264ve_64!???+00000000 : 7FF9E7D21EE6
 mfx_mft_h264ve_64!???+00000000 : 7FF9E7D22A13
 mfx_mft_h264ve_64!???+00000000 : 7FF9E7D15A48
 test2!MF::H264Encoder::ProcessInput+00000112 (c:\users\reach\desktop\hlx\test\test2\mf-h264-encoder.cpp, 529)
 test2!MF::H264Encoder::ProcessInput2+000006F4 (c:\users\reach\desktop\hlx\test\test2\mf-h264-encoder.cpp, 693)
 test2!MFH264_Encode+000000D7 (c:\users\reach\desktop\hlx\test\test2\mf-h264.cpp, 500)
 test2!EncodeThread+000002E2 (c:\users\reach\desktop\hlx\test\test2\mf-h264.cpp, 661)
 KERNEL32!BaseThreadInitThunk+00000014
 ntdll!RtlUserThreadStart+00000021

+  625000 ( 625000 -      0)      1 allocs BackTraceFE376151
+       1 (      1 -      0) BackTraceFE376151 allocations

 ntdll!RtlpCallInterceptRoutine+0000003F
 ntdll!RtlpAllocateHeapInternal+00001142
 msvcrt!malloc+00000070
 MFPlat!MFTraceFuncEnter+00000257
 MFPlat!MFCreateMemoryBuffer+0000054C
 mfx_mft_h264ve_64!DllGetClassObject+0003FC57
 mfx_mft_h264ve_64!DllGetClassObject+00041155
 mfx_mft_h264ve_64!DllGetClassObject+00040F57
 mfx_mft_h264ve_64!???+00000000 : 7FF9E7D1F831
 mfx_mft_h264ve_64!???+00000000 : 7FF9E7D2069E
 mfx_mft_h264ve_64!???+00000000 : 7FF9E7D2269E
 mfx_mft_h264ve_64!???+00000000 : 7FF9E7D15A48
 test2!MF::H264Encoder::ProcessInput+00000112 (c:\users\reach\desktop\hlx\test\test2\mf-h264-encoder.cpp, 529)
 test2!MF::H264Encoder::ProcessInput2+000006F4 (c:\users\reach\desktop\hlx\test\test2\mf-h264-encoder.cpp, 693)
 test2!MFH264_Encode+000000D7 (c:\users\reach\desktop\hlx\test\test2\mf-h264.cpp, 500)
 test2!EncodeThread+000002E2 (c:\users\reach\desktop\hlx\test\test2\mf-h264.cpp, 661)
 KERNEL32!BaseThreadInitThunk+00000014
 ntdll!RtlUserThreadStart+00000021

+  625000 ( 625000 -      0)      1 allocs BackTraceFE92B7D1
+       1 (      1 -      0) BackTraceFE92B7D1 allocations

 ntdll!RtlpCallInterceptRoutine+0000003F
 ntdll!RtlpAllocateHeapInternal+00001142
 msvcrt!malloc+00000070
 MFPlat!MFTraceFuncEnter+00000257
 MFPlat!MFCreateMemoryBuffer+0000054C
 mfx_mft_h264ve_64!DllGetClassObject+0003FC57
 mfx_mft_h264ve_64!DllGetClassObject+00040095
 mfx_mft_h264ve_64!DllGetClassObject+0004062D
 mfx_mft_h264ve_64!???+00000000 : 7FF9E7D22E7F
 mfx_mft_h264ve_64!???+00000000 : 7FF9E7D15C47
 test2!MF::H264Encoder::ProcessOutput+00000453 (c:\users\reach\desktop\hlx\test\test2\mf-h264-encoder.cpp, 741)
 test2!MF::H264Encoder::ProcessOutput+00000037 (c:\users\reach\desktop\hlx\test\test2\mf-h264-encoder.cpp, 817)
 test2!MFH264_Encode+00000137 (c:\users\reach\desktop\hlx\test\test2\mf-h264.cpp, 510)
 test2!EncodeThread+000002E2 (c:\users\reach\desktop\hlx\test\test2\mf-h264.cpp, 661)
 KERNEL32!BaseThreadInitThunk+00000014
 ntdll!RtlUserThreadStart+00000021

I am using the win10 /

processor:  Intel(R)_Core(TM)_i7-6500U_CPU_@_2.50GHz   version :10.0.14393.0

the graphic driver :Intel(R) HD Graphics 520  version 20.19.15.4483

 ,

0 Kudos
1 Reply
lixiang_h_
Beginner
95 Views

follow code:

HRESULT H264Encoder::ProcessInput(ComPtr<IMFSample> &sample)
{
 HRESULT hr = S_OK;
 if (m_descriptor->Async()) {
  if (inputRequests == 1 && inputSamples.empty()) {
   inputRequests--;
   return transform->ProcessInput(0, sample, 0); // line 529    : memory leak
  }

  inputSamples.push(sample);

  while (inputRequests > 0) {
   if (inputSamples.empty())
    return hr;
   ComPtr<IMFSample> queuedSample = inputSamples.front();
   inputSamples.pop();
   inputRequests--;
   HRC(transform->ProcessInput(0, queuedSample, 0));
  }
 } else {
  return transform->ProcessInput(0, sample, 0);
 }

fail:
 return hr;
}

Reply