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. QueryInterface Regarding....

QueryInterface Regarding....

Scheduled Pinned Locked Moved COM
questioncomperformancehelpannouncement
2 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.
  • G Offline
    G Offline
    ganesa moorthy
    wrote on last edited by
    #1

    Hi, My Program is supposed to run contineously so i need to concern about memory management with COM. Here is the scenario, I created a COM Object using CreateInstance() using that COM object i am creating another object using QueryInterface. Here is my question. 1. if i am releasing the first object which i got using CreateInstance, then subsequently the objects which are created using that will be removed from memory right? Since if i call release for object got using QI causing crash. But i am fine if i release the first object, but i am afraid this would lead to a memory leak issue. :( Kindly Advice! Thanks in advance:rose: -Ganesha

    Thanks a lot

    R 1 Reply Last reply
    0
    • G ganesa moorthy

      Hi, My Program is supposed to run contineously so i need to concern about memory management with COM. Here is the scenario, I created a COM Object using CreateInstance() using that COM object i am creating another object using QueryInterface. Here is my question. 1. if i am releasing the first object which i got using CreateInstance, then subsequently the objects which are created using that will be removed from memory right? Since if i call release for object got using QI causing crash. But i am fine if i release the first object, but i am afraid this would lead to a memory leak issue. :( Kindly Advice! Thanks in advance:rose: -Ganesha

      Thanks a lot

      R Offline
      R Offline
      Roger Stoltz
      wrote on last edited by
      #2

      Unless the second object is aggregated in the COM sense, i.e. it's a server that lives inside another server, thou-shall-not-create-objects-with-QueryInterface! QueryInterface has a well-defined purpose and functionality: you ask a COM object you already have an interface to for another interface, the object returns that interface if it implements it and fails with E_NOINTERFACE if it does not implement the requested interface. If such functionality is desired you should create an interface function that clearly says it will create another COM object.

      ganesa moorthy wrote:

      if i am releasing the first object which i got using CreateInstance, then subsequently the objects which are created using that will be removed from memory right?

      Not if the object still has clients, i.e. it's reference count has not reached zero. It looks to me as you two objects are too tightly connected. If you make them available in the same server (COM object) but perhaps reachable from different interfaces, you can use QueryInterface correctly. Another alternative is to make the two objects less connected and actually have two different COM objects.

      "It's supposed to be hard, otherwise anybody could do it!" - selfquote
      "High speed never compensates for wrong direction!" - unknown

      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