Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. WMF's IWMReader memory leak?

WMF's IWMReader memory leak?

Scheduled Pinned Locked Moved C / C++ / MFC
comadobesysadminperformancequestion
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Philip Patrick
    wrote on last edited by
    #1

    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 call Close and Release 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

    M 1 Reply Last reply
    0
    • P Philip Patrick

      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 call Close and Release 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

      M Offline
      M Offline
      Michael Dunn
      wrote on last edited by
      #2

      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."   -- Buffy

      P 1 Reply Last reply
      0
      • M Michael Dunn

        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."   -- Buffy

        P Offline
        P Offline
        Philip Patrick
        wrote on last edited by
        #3

        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

        M 1 Reply Last reply
        0
        • P Philip Patrick

          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

          M Offline
          M Offline
          Michael Dunn
          wrote on last edited by
          #4

          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."

          P 1 Reply Last reply
          0
          • M Michael Dunn

            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."

            P Offline
            P Offline
            Philip Patrick
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups