Author Topic: error: null interface pointer ..  (Read 18626 times)

0 Members and 1 Guest are viewing this topic.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: error: null interface pointer ..
« Reply #45 on: November 04, 2005, 08:47:12 AM »
That was a good explanation. :-)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: error: null interface pointer ..
« Reply #46 on: November 04, 2005, 08:56:43 AM »
Good job Steve.

Here's a related thread started by ... Will DeLoach=> link.

:)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: error: null interface pointer ..
« Reply #47 on: November 04, 2005, 09:01:26 AM »
On nesting and performance here's one that may be interesing => link.

Or not.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: error: null interface pointer ..
« Reply #48 on: November 04, 2005, 09:04:34 AM »
As is this one => link.

Very interesting indeed.

:)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

whdjr

  • Guest
Re: error: null interface pointer ..
« Reply #49 on: November 04, 2005, 10:11:08 AM »
Excellent job on the explanation Steve.  However if my brain was worth a fart I might remember this discussion from earlier as MP pointed out.
Good job Steve.

Here's a related thread started by ... Will DeLoach=> link.

:)

Thanks for the reminder MP.  It seems most things go in one ear and out the other these days.  Just too much work to remember anything.

Sdoman

  • Guest
Re: error: null interface pointer ..
« Reply #50 on: November 04, 2005, 03:02:42 PM »
Thanks for the kudos you all. 

I started to read the threads that MP referred to.  They look very interesting indeed, but I'm going to have to go back and read them later when I have more time.  Thanks!

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: error: null interface pointer ..
« Reply #51 on: November 09, 2005, 08:45:32 AM »
Something else that MAY be interesting
>>>>>

(vlax-release-object xxDoc)
;->> 3   <- This is the current reference count on the Active document.


>>>>>

I've had second thought about the value returned from (vlax-release-object ...
It is undocumented in the help files, and despite my best guesses, I cant demonstrate with certainty what this number represents.



kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Glenn R

  • Guest
Re: error: null interface pointer ..
« Reply #52 on: January 21, 2006, 09:39:19 PM »
Hmmm...interesting discussion (which I missed originally).

Here's my 2 bucks worth.

From my C++ COM development I learned a lot of things, in particular about the internal working of a COM object as far as the low level C++ side is concerned and a few more general concepts, but the most important is this:

1. C++ is difficult; COM is hard; GOOD COM is very hard.

Throughout this thread, there was much mention of 'pointers' to objects and the like, but I believe there are some misconceptions about those magic 'pointers'.
In a nutshell, a COM Class holds an internal reference to the object it is describing and for all intents and purposes it is static. Think of it like a global lisp variable, or a private internal variable (for the .NET people).

Now, the FIRST time some chunk of code asks for this 'object', the COM component spins up an instance of it's internal object, and here's the important bit, creates a NEW POINTER TO THE INTERFACE of the OBJECT (AddRef), NOT a pointer to the internal object itself. The internal OBJECT is created only ONCE - EVER.

The next thing it does, is increment it's INTERFACE reference counter by one and pass back the pointer. At this time the calling code can do what it likes.
Remember, this is a pointer to an INTERFACE, NOT THE INTERNAL OBJECT as such. This process is repeated again and again as required by the clients of this COM object.

Now, to release or not? One of the classic 'bad' things about COM is memory management (leaks) and this comes about through the reference counting that the COM Object implements (badly in this case) and calling code.

Setting a COM object reference to nil/nothing/null is SUPPOSED to inform the COM CLASS OBJECT to decrement it's internal reference count by one. This process repeats again and again, untill the internal counter reaches 0. When this happens, the COM Class object destroys it's internal object (the real one you're interested in) and frees the memory allocated by this object back to the pool.

As far as the release question goes, I would adopt the same pattern as in C++ - if you NEW'em, DELETE'em...pure and simple. And I suspect the reason releasing the acad object doesn't ever get the count to 0 is that AutoCAD itself is hanging onto some interface pointers for internal reasons (vlisp being one). Let's face it, you wouldn't want the reference count to the Acad Application itself to reach 0 whilst your code was running would you?

Just some ramblings that may or may not help.

Cheers,
Glenn.