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#
  4. How to know if unmanaged object is not in memory?

How to know if unmanaged object is not in memory?

Scheduled Pinned Locked Moved C#
helpcomperformancetutorialquestion
5 Posts 3 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
    AksharRoop
    wrote on last edited by
    #1

    Problem Statement: How to know if unmanaged com object is deleted from memory. Problem Description: I have unmanaged object instance in one class. When closing application this object is is destructed from other part of code. And it also comes to point where object is member of class to do some final clear stuff. When it tried to access this com object (which has already been deleted from memory) it throws memory access violation error. Is there any way to know if this object still exist? Thanks, AksharRoop

    S 1 Reply Last reply
    0
    • A AksharRoop

      Problem Statement: How to know if unmanaged com object is deleted from memory. Problem Description: I have unmanaged object instance in one class. When closing application this object is is destructed from other part of code. And it also comes to point where object is member of class to do some final clear stuff. When it tried to access this com object (which has already been deleted from memory) it throws memory access violation error. Is there any way to know if this object still exist? Thanks, AksharRoop

      S Offline
      S Offline
      Som Shekhar
      wrote on last edited by
      #2

      Check if it is null?

      A 1 Reply Last reply
      0
      • S Som Shekhar

        Check if it is null?

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

        I hope I atleast know this!! The object is not null. It holds a pointer to an object. so here it is a 'dangling ptr' kind of situation.

        D 1 Reply Last reply
        0
        • A AksharRoop

          I hope I atleast know this!! The object is not null. It holds a pointer to an object. so here it is a 'dangling ptr' kind of situation.

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          Not so much "dangling pointer", but orphaned. The only way to see if it still exists is to check the pointer to it for null. If you're worried about orphaning pointers, make sure you're those pointers to other objects are null before you kill the parent object.

          A guide to posting questions on CodeProject[^]
          Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
               2006, 2007, 2008
          But no longer in 2009...

          S 1 Reply Last reply
          0
          • D Dave Kreskowiak

            Not so much "dangling pointer", but orphaned. The only way to see if it still exists is to check the pointer to it for null. If you're worried about orphaning pointers, make sure you're those pointers to other objects are null before you kill the parent object.

            A guide to posting questions on CodeProject[^]
            Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                 2006, 2007, 2008
            But no longer in 2009...

            S Offline
            S Offline
            Som Shekhar
            wrote on last edited by
            #5

            Thanks Dave, I wrote a similar reply but just happened to see that there was another comment :D

            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