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. COM
  4. How to keep a C++ com dll in memory?

How to keep a C++ com dll in memory?

Scheduled Pinned Locked Moved COM
c++comwindows-adminperformancetutorial
4 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.
  • A Offline
    A Offline
    Anonymously
    wrote on last edited by
    #1

    I have a com dll written in C++ which is used in asp applications. The dll contains only one com object. There are static (global to the process) data objects within this dll. Obviously, I only want to initialize these static objects when the dll is first loaded. However, IIS seems to be reloading my dll everytime the com object is created and used in an asp page.

    P 1 Reply Last reply
    0
    • A Anonymously

      I have a com dll written in C++ which is used in asp applications. The dll contains only one com object. There are static (global to the process) data objects within this dll. Obviously, I only want to initialize these static objects when the dll is first loaded. However, IIS seems to be reloading my dll everytime the com object is created and used in an asp page.

      P Offline
      P Offline
      pba_
      wrote on last edited by
      #2

      The proper way to do it is to make your server a service, if your objects need to have some context setup once per session. The answer to your question is to return allways S_FALSE from DllCanUnloadNow. In case you are using ATL you can achieve this by having a CAtlModule::Lock call without CAtlModule::Unlock pair.

      A 1 Reply Last reply
      0
      • P pba_

        The proper way to do it is to make your server a service, if your objects need to have some context setup once per session. The answer to your question is to return allways S_FALSE from DllCanUnloadNow. In case you are using ATL you can achieve this by having a CAtlModule::Lock call without CAtlModule::Unlock pair.

        A Offline
        A Offline
        Anonymously
        wrote on last edited by
        #3

        Thanks for the help. I don't want to make my com dll a service right now. I tried to return S_FALSE in DllCanUnloadNow and also called CAtlModule::Lock without calling Unlock. Doesn't seem to work. I remember when building a com dll in VB6, you can specify a project setting called "retained in memory" which will do exactly what I want. Is there an equivalent of this feature in VC++?

        P 1 Reply Last reply
        0
        • A Anonymously

          Thanks for the help. I don't want to make my com dll a service right now. I tried to return S_FALSE in DllCanUnloadNow and also called CAtlModule::Lock without calling Unlock. Doesn't seem to work. I remember when building a com dll in VB6, you can specify a project setting called "retained in memory" which will do exactly what I want. Is there an equivalent of this feature in VC++?

          P Offline
          P Offline
          pba_
          wrote on last edited by
          #4

          Returning S_FALSE from DllCanUnloadNow should leave the dll loaded. I don't know VB, so I cannot tell exactly what that property does, but I suppose it will do the same thing ( return false from can unload now). Did you check if it's the same process ? ( maybe the process will exit, so normally all the dlls will be unloaded).

          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