Memory usage with ReadSample #14
-
|
Hi all, I've read your discussion on the topic: I'm using critical section and releasing the sample (=nil), but still the memory usage seems to keep going up.. Even after the source reader is flushed and closed the memory usage does not seem to free up completely. Is this still a known memory issue with media foundation? Or perhaps I'm still missing something. Admittedly i'm using version: 2.6.1, so upgrading to 3.0.1 will be my next step, in case some calls have been updated to fix this. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 34 replies
-
|
Hi, See: Example MfAudioClipEx (function TAudioClipClass.OnReadSample) Although I think you need to implement a callback function from IMFMediaEvent, that reports when a sample is processed, before processing the next one, as usual in a-synchronous mode. I think function IMFMediaEvent.GetStatus(out phrStatus: HRESULT) could do the job. Right now I'm working on a WASAPI component that should render RAW/WAV formats. (See: Examples\MFComponents\WasApiRenderFile.pas. That is not working yet. Greeting, Tony. |
Beta Was this translation helpful? Give feedback.
-
|
Hi Tony, Thanks for your reply. Unfortunately, I haven't had any luck with that solution either. This example below is the memory in use, when reading a single video frame sample.
As you can see, the memory is nearly freed up after destroying the source reader, but not before.. Edit - I can put together a sample project demonstrating this, if that would be of use. |
Beta Was this translation helpful? Give feedback.
-
|
Hi Tony, I've added a sample frame capture project here: Let me know if you see any ways to improve it. Ideally, I'll update it to have an asynchronous capture example as the memory issue does not seem as bad with this synchronous code. If you think this sample project is of use for MfPack, I can open a pull request 👍 |
Beta Was this translation helpful? Give feedback.

Hi,
To fix this issue, I implemented MsgWaitForMultipleObjects to give the
ReadSample method more time to organize it's sample pool with in the OnReadSample function, alternatively you can use the Sleep() method.
See: Example MfAudioClipEx (function TAudioClipClass.OnReadSample)
Although I think you need to implement a callback function from IMFMediaEvent, that reports when a sample is processed, before processing the next one, as usual in a-synchronous mode. I think function IMFMediaEvent.GetStatus(out phrStatus: HRESULT) could do the job.
Right now I'm working on a WASAPI component that should render RAW/WAV formats. (See: Examples\MFComponents\WasApiRenderFile.pas. That is not working …