WMF's IWMReader memory leak?
-
Anyone experienced any problems (memory leaks in my case) with Windows Media Format SDK? I'm using it to retrieve content from network and write to local disk, but looks like it has a memory leak. This is the code I use:
IWMReader\* pReader = NULL; m\_hEvent = CreateEvent(NULL, FALSE, FALSE, NULL); HRESULT hr = WMCreateReader(NULL, WMT\_RIGHT\_PLAYBACK, &pReader); pReader->Open(L"some\_url\_here", this, NULL); WaitForSingleObject(m\_hEvent, 60000); pReader->Close(); pReader->Release(); CloseHandle(m\_hEvent);
Both callback functions (OnStatus and OnSample) are empty, just returning S_OK. You see, I'm not starting it, only opening. After I call
Open
function, memory jumps for about 2.5Mb. When I callClose
andRelease
it goes down around 1.Mb, leaving 1.5Mb in "air". Anyone knows about this? Philip Patrick Web-site: www.stpworks.com "Two beer or not two beer?" Shakesbeer -
Anyone experienced any problems (memory leaks in my case) with Windows Media Format SDK? I'm using it to retrieve content from network and write to local disk, but looks like it has a memory leak. This is the code I use:
IWMReader\* pReader = NULL; m\_hEvent = CreateEvent(NULL, FALSE, FALSE, NULL); HRESULT hr = WMCreateReader(NULL, WMT\_RIGHT\_PLAYBACK, &pReader); pReader->Open(L"some\_url\_here", this, NULL); WaitForSingleObject(m\_hEvent, 60000); pReader->Close(); pReader->Release(); CloseHandle(m\_hEvent);
Both callback functions (OnStatus and OnSample) are empty, just returning S_OK. You see, I'm not starting it, only opening. After I call
Open
function, memory jumps for about 2.5Mb. When I callClose
andRelease
it goes down around 1.Mb, leaving 1.5Mb in "air". Anyone knows about this? Philip Patrick Web-site: www.stpworks.com "Two beer or not two beer?" ShakesbeerIs the memory usage going up by 1.5MB for every file, or just the first? If it's just the first then that's normal. The first time you use any in-proc COM server, your process has to load the server DLL (and any others that it uses) so your working set will increase. If the working set is an issue, call
CoFreeUnusedLibraries()
to try to unload in-proc servers with a ref count of 0. --Mike-- Ericahist [updated Oct 26] | CP SearchBar v2.0.2 | Homepage | RightClick-Encrypt | 1ClickPicGrabber "That probably would've sounded more commanding if I wasn't wearing my yummy sushi pajamas." -- Buffy -
Is the memory usage going up by 1.5MB for every file, or just the first? If it's just the first then that's normal. The first time you use any in-proc COM server, your process has to load the server DLL (and any others that it uses) so your working set will increase. If the working set is an issue, call
CoFreeUnusedLibraries()
to try to unload in-proc servers with a ref count of 0. --Mike-- Ericahist [updated Oct 26] | CP SearchBar v2.0.2 | Homepage | RightClick-Encrypt | 1ClickPicGrabber "That probably would've sounded more commanding if I wasn't wearing my yummy sushi pajamas." -- BuffyWell it happens every time I create and open IWMReader. For example (not the full code, just to keep it simple):
WMCreateReader(NULL, WMT_RIGHT_PLAYBACK, &pReader);
pReader->Open(L"URL");
pReader->Close();
pReader->Release();put this in loop and you get the memory to 100Mb in just a few minutes. But if you won't call Release (and of course won't create it again), mean just Open and Close, then everything is ok. I'll try your suggestion though tomorrow at work. Will see if this is the problem. Thank you :) Philip Patrick Web-site: www.stpworks.com "Two beer or not two beer?" Shakesbeer
-
Well it happens every time I create and open IWMReader. For example (not the full code, just to keep it simple):
WMCreateReader(NULL, WMT_RIGHT_PLAYBACK, &pReader);
pReader->Open(L"URL");
pReader->Close();
pReader->Release();put this in loop and you get the memory to 100Mb in just a few minutes. But if you won't call Release (and of course won't create it again), mean just Open and Close, then everything is ok. I'll try your suggestion though tomorrow at work. Will see if this is the problem. Thank you :) Philip Patrick Web-site: www.stpworks.com "Two beer or not two beer?" Shakesbeer
Philip Patrick wrote: put this in loop and you get the memory to 100Mb hmmm, that is worrysome. Which version of the FSDK? I use the FSDK at work, and it's possible that a user could end up doing similar code in a loop over many files, so I'll give it a try at work tomorrow too. --Mike-- Ericahist [updated Oct 26] | CP SearchBar v2.0.2 | Homepage | RightClick-Encrypt | 1ClickPicGrabber Actual sign at the laundromat I go to: "No tinting or dying."
-
Philip Patrick wrote: put this in loop and you get the memory to 100Mb hmmm, that is worrysome. Which version of the FSDK? I use the FSDK at work, and it's possible that a user could end up doing similar code in a loop over many files, so I'll give it a try at work tomorrow too. --Mike-- Ericahist [updated Oct 26] | CP SearchBar v2.0.2 | Homepage | RightClick-Encrypt | 1ClickPicGrabber Actual sign at the laundromat I go to: "No tinting or dying."
Using the latest version. But... Now it is something I don't understand at all. The "memory leak" is really depend on the source. I found sources that the same code doesn't produce any leak and sources that it does (all of them have a video stream). Not sure what happens here. Philip Patrick Web-site: www.stpworks.com "Two beer or not two beer?" Shakesbeer