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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to unload WinHttp library?

How to unload WinHttp library?

Scheduled Pinned Locked Moved C / C++ / MFC
performancehelptutorialquestionannouncement
6 Posts 5 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.
  • M Offline
    M Offline
    MarxF
    wrote on last edited by
    #1

    My code looks like this:

    int CMainClass::Start()
    {
    .......
    for(int = 0; iGetList(); // I need a method in the CMainClass
    return 0;
    }
    ........
    int CMainClass::GetList()
    {
    HINSTANCE hLibrary = LoadLibrary(L"winhttp.dll");
    ........
    // Call some winhttp.dll functions.
    ........
    FreeLibrary(hLibrary);
    return 0;
    }

    My problem is that despite the call to FreeLibrary(), winhttp.dll is not unloaded. Each new thread I create allocate memory in the heap, but the call to FreeLibrary() does not release that memory. Is there a way to force the unloading of the library and the release of the memory? Thank you!

    J J 2 Replies Last reply
    0
    • M MarxF

      My code looks like this:

      int CMainClass::Start()
      {
      .......
      for(int = 0; iGetList(); // I need a method in the CMainClass
      return 0;
      }
      ........
      int CMainClass::GetList()
      {
      HINSTANCE hLibrary = LoadLibrary(L"winhttp.dll");
      ........
      // Call some winhttp.dll functions.
      ........
      FreeLibrary(hLibrary);
      return 0;
      }

      My problem is that despite the call to FreeLibrary(), winhttp.dll is not unloaded. Each new thread I create allocate memory in the heap, but the call to FreeLibrary() does not release that memory. Is there a way to force the unloading of the library and the release of the memory? Thank you!

      J Offline
      J Offline
      jschell
      wrote on last edited by
      #2

      Member 10215814 wrote:

      Each new thread I create allocate memory in the heap, but the call to FreeLibrary() does not release that memory.

      What makes you think that the first is related to the second?

      M 1 Reply Last reply
      0
      • J jschell

        Member 10215814 wrote:

        Each new thread I create allocate memory in the heap, but the call to FreeLibrary() does not release that memory.

        What makes you think that the first is related to the second?

        M Offline
        M Offline
        MarxF
        wrote on last edited by
        #3

        I'm not sure I understand your question... I have no memory leaks and I see the memory usage increasing at every new created thread. So I presume that the "per-thread" heap memory is not released by the call to FreeLibrary().

        L D 2 Replies Last reply
        0
        • M MarxF

          I'm not sure I understand your question... I have no memory leaks and I see the memory usage increasing at every new created thread. So I presume that the "per-thread" heap memory is not released by the call to FreeLibrary().

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          MarxF wrote:

          I presume that the "per-thread" heap memory is not released by the call to FreeLibrary().

          Why would it be? The two are not related.

          1 Reply Last reply
          0
          • M MarxF

            My code looks like this:

            int CMainClass::Start()
            {
            .......
            for(int = 0; iGetList(); // I need a method in the CMainClass
            return 0;
            }
            ........
            int CMainClass::GetList()
            {
            HINSTANCE hLibrary = LoadLibrary(L"winhttp.dll");
            ........
            // Call some winhttp.dll functions.
            ........
            FreeLibrary(hLibrary);
            return 0;
            }

            My problem is that despite the call to FreeLibrary(), winhttp.dll is not unloaded. Each new thread I create allocate memory in the heap, but the call to FreeLibrary() does not release that memory. Is there a way to force the unloading of the library and the release of the memory? Thank you!

            J Offline
            J Offline
            Jochen Arndt
            wrote on last edited by
            #5

            As already noted, there is no relation between the mapping of the library into the address space of your process and the memory allocated by your threads. LoadLibrary works per process, not per thread. So you add can add a HINSTANCE member variable to your class, load the library from within the constructor or your Start() function, and free the library in the destructor.

            1 Reply Last reply
            0
            • M MarxF

              I'm not sure I understand your question... I have no memory leaks and I see the memory usage increasing at every new created thread. So I presume that the "per-thread" heap memory is not released by the call to FreeLibrary().

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #6

              A common misconception about Task Manager numbers is that they tell something about the memory your program is consuming. This is not what those numbers tell you. They tell you the amount of address space that is in use. This has nothing to do with the amount of that address space your program is actually using. The blocks of memory that your code, or the library, freed are still in the address space, but they are available for subsequent allocation. The numbers you see in Task Manager are almost but not quite completely useless for telling how much of your memory is in use. If you see it shrink, this is good, but if you don't, it is not necessarily bad. If it's really important to you, use the heap-walking functions to track what is going on.

              "One man's wage rise is another man's price increase." - Harold Wilson

              "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

              "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

              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