Interface reference counting

I rarely using Interface objects in my application development, no joke 
although it is weired.
When I create objects implement interface, eg

TMyObject1 implements interface1.
TMyObject2 implements interface1.

I create instances for TMyObject1 and TMyObject2.

Does interface1 has count 2?

Or I have totally wrong in concept?
0
Pak
12/28/2008 10:45:37 PM
embarcadero.delphi.general 4258 articles. 0 followers. Follow

21 Replies
721 Views

Similar Articles

[PageSpeed] 12

Pak Tse wrote:

> Does interface1 has count 2?

No. Interface references are counted, not object
references. See http://dn.codegear.com/article/30125 for an
explanation.

-- 
Bill Todd (TeamB)
0
Bill
12/28/2008 11:08:13 PM
A better article is http://dn.codegear.com/article/27825

-- 
Bill Todd (TeamB)
0
Bill
12/28/2008 11:51:53 PM
>A better article is http://dn.codegear.com/article/27825
After an intial read of the article, just want to know if my understanding.
Such as in the article, if I have the statement:

procedure TForm1.Button1Click(Sender: TObject);
var
  v1, v2: IVersionInfo;
begin
  v1 := (VersionComponent1 as IVersionInfo);
  Caption := IntToStr(v1.MajorVersion) + '.' +
             IntToStr(v1.MinorVersion) + '.' +
             IntToStr(v1.Build);  v2 := (VersionComponent1 as IVersionInfo);
  Caption := IntToStr(v2.MajorVersion) + '.' +
             IntToStr(v2.MinorVersion) + '.' +
             IntToStr(v2.Build);

end;Before the end of the ButtonClick event, the reference count of 
interface IVersionInfo should be 2, right?

Once the click event is finished, returned control back to main form, the 
reference count is 0. Then the objects v1 and v2 are freed. Am I correct?
0
Pak
12/29/2008 4:45:00 AM
Sorry, the statement should be as follows, please ignore my previous thread:

 After an intial read of the article, just want to know if my understanding.
 Such as in the article, if I have the statement:

 procedure TForm1.Button1Click(Sender: TObject);
 var
  v1, v2: IVersionInfo;
 begin
  v1 := TVersionComponent.Create(self);
  Caption := IntToStr(v1.MajorVersion) + '.' +
                   IntToStr(v1.MinorVersion) + '.' +
                   IntToStr(v1.Build);

  v2 := TVersionComponent.Create(self);
  Caption := IntToStr(v2.MajorVersion) + '.' +
                   IntToStr(v2.MinorVersion) + '.' +
                   IntToStr(v2.Build);

 end;Before the end of the ButtonClick event, the reference count of
 interface IVersionInfo should be 2, right?

 Once the click event is finished, returned control back to main form, the
 reference count is 0. Then the objects v1 and v2 are freed. Am I correct?
0
Pak
12/29/2008 4:49:39 AM
Pak Tse wrote:

> Once the click event is finished, returned control back
> to main form, the reference count is 0. Then the objects
> v1 and v2 are freed. Am I correct?

Correct.

-- 
Bill Todd (TeamB)
0
Bill
12/29/2008 3:42:30 PM
> {quote:title=Pak Tse wrote:}{quote}
> ...
>  procedure TForm1.Button1Click(Sender: TObject);
>  var
>   v1, v2: IVersionInfo;
>  begin
>   v1 := TVersionComponent.Create(self);
>   Caption := IntToStr(v1.MajorVersion) + '.' +
>                    IntToStr(v1.MinorVersion) + '.' +
>                    IntToStr(v1.Build);
> 
>   v2 := TVersionComponent.Create(self);
>   Caption := IntToStr(v2.MajorVersion) + '.' +
>                    IntToStr(v2.MinorVersion) + '.' +
>                    IntToStr(v2.Build);
> 
>  end;Before the end of the ButtonClick event, the reference count of
>  interface IVersionInfo should be 2, right?
> 
>  Once the click event is finished, returned control back to main form, the
>  reference count is 0. Then the objects v1 and v2 are freed. Am I correct?

NO! When you are implementing an interface, the reference-counting (and auto-releasing) is left to your implementation. TComponent doesn't support auto-releasing, so you create two different objects and after finishing the onclick event the objects still exists. Because you are passing an owner, the objects will finally be released when the main form closes.

If you would derrive from TInterfacedObject (which has built in support for reference-counting), then you would create two different objects. Each object is referenced by 1 variable, so there reference counter would be 1 for each. At the end of the onclick event, the compiler would call "_Release" and the implementation of TInterfacedObject would free the object.

Regards:
Martin
0
Martin
12/29/2008 9:57:58 PM
<Martin Stoeckli> wrote in message news:60568@forums.codegear.com...
>> {quote:title=Pak Tse wrote:}{quote}
>> ...
>>  procedure TForm1.Button1Click(Sender: TObject);
>>  var
>>   v1, v2: IVersionInfo;
>>  begin
>>   v1 := TVersionComponent.Create(self);
>>   Caption := IntToStr(v1.MajorVersion) + '.' +
>>                    IntToStr(v1.MinorVersion) + '.' +
>>                    IntToStr(v1.Build);
>>
>>   v2 := TVersionComponent.Create(self);
>>   Caption := IntToStr(v2.MajorVersion) + '.' +
>>                    IntToStr(v2.MinorVersion) + '.' +
>>                    IntToStr(v2.Build);
>>
>>  end;Before the end of the ButtonClick event, the reference count of
>>  interface IVersionInfo should be 2, right?
>>
>>  Once the click event is finished, returned control back to main form, 
>> the
>>  reference count is 0. Then the objects v1 and v2 are freed. Am I 
>> correct?
>
> NO! When you are implementing an interface, the reference-counting (and 
> auto-releasing) is left to your >implementation. TComponent doesn't 
> support auto-releasing, so you create two different objects and after 
>  >finishing the onclick event the objects still exists. Because you are 
> passing an owner, the objects will finally be >released when the main form 
> closes.
>
> If you would derrive from TInterfacedObject (which has built in support 
> for reference-counting), then you >would create two different objects. 
> Each object is referenced by 1 variable, so there reference counter would 
>  >be 1 for each. At the end of the onclick event, the compiler would call 
> "_Release" and the implementation of >TInterfacedObject would free the 
> object.

Sorry,
so in my case above, the reference counting does not work because of using 
this statement:
v2 := TVersionComponent.Create(self);
OR
TVersionComponent is descendant of TComponent?

What if
TVersionComponent = class (TMyAnyClass, IVersionInfo)
......
?

I think I still in the dark.
0
Pak
12/29/2008 10:15:34 PM
Pak Tse a écrit :

> Sorry,
> so in my case above, the reference counting does not work because of using 
> this statement:
> v2 := TVersionComponent.Create(self);
> OR
> TVersionComponent is descendant of TComponent?
 >
 > What if
 > TVersionComponent = class (TMyAnyClass, IVersionInfo)
 > .....
 > ?

Reference counting only works if the class implementing an interface 
either derives from TInterfacedObject or, at least, implements _AddRef, 
_Release and QueryInterface in the same manner as TInterfacedObject.

Joanna

-- 
Joanna Carter [TeamB|http://www.teamb.com]
Consultant Software Engineer
0
Joanna
12/29/2008 11:23:47 PM
Martin is right. I assumed TVersionComponent descended from
TInterfacedObject. Reference counting only works if the
class implements reference counting. TInterfaced object
does but TComponent does not.

-- 
Bill Todd (TeamB)
0
Bill
12/30/2008 12:03:58 AM
> Martin is right. I assumed TVersionComponent descended from
> TInterfacedObject. Reference counting only works if the
> class implements reference counting. TInterfaced object
> does but TComponent does not.

How about I rephrase my question to ignore my previous, and the new 
situation as follows:

- IVersionInfo inherit from TInterfacedObject
- TVersionClass = class (TMyAnyClass, IVersionInfo)

procedure TForm1.Button1Click(Sender: TObject);
var
   v1, v2, v3, v4: IVersionInfo;
begin
   v1 := TVersionClass.Create(self);
   v2 := TVersionClass.Create(self);
   MyProcess1;
   v3 := TVersionClass.Create(self);
   v4 := TVersionClass.Create(self);
end;

procedure TForm1.MyProcess1;
var
   vA, vB: IVersionInfo;
begin
   vA := TVersionClass.Create(self);
   vB := TVersionClass.Create(self);
end;

When I click the button1, what will be the reference count of the interface 
"IVersionInfo":
1) before calling MyProcess1?
2) first entering the MyProcess1?
3) before exit MyProcess1?
4) when back to Button1Click event from MyProcess1?
5) exit Button1Click event?
0
Pak
12/30/2008 4:56:17 AM
Pak Tse a écrit :

> How about I rephrase my question to ignore my previous, and the new 
> situation as follows:
> 
> - IVersionInfo inherit from TInterfacedObject

Unless this is a typo, this is not possible; an interface cannot inherit
from a class.

> - TVersionClass = class (TMyAnyClass, IVersionInfo)

However, TVersionClass should inherit from TInterfacedObject :

type
   TVersionClass = class (TInterfacedObject, IVersionInfo)

> When I click the button1, what will be the reference count of the
> interface "IVersionInfo":

I'm sorry but you really have got hold of the wrong idea here.
Interfaces do not hold reference counts, it is the variables that hold
interfaces that have reference counts.

procedure TForm1.Button1Click(Sender: TObject);
var
   v1, v2, v3, v4: IVersionInfo;
begin
   v1 := TVersionClass.Create(self);

   // v1 has a reference count of 1;
   // v2 is unassigned;
   // v3 is unassigned;
   // v4 is unassigned;


   v2 := TVersionClass.Create(self);

   // v1 has a reference count of 1;
   // v2 has a reference count of 1;
   // v3 is unassigned;
   // v4 is unassigned;

   MyProcess1;

   // v1 has a reference count of 1;
   // v2 has a reference count of 1;
   // v3 is unassigned;
   // v4 is unassigned;

   v3 := TVersionClass.Create(self);

   // v1 has a reference count of 1;
   // v2 has a reference count of 1;
   // v3 has a reference count of 1;
   // v4 is unassigned;

   v4 := TVersionClass.Create(self);

   // v1 has a reference count of 1;
   // v2 has a reference count of 1;
   // v3 has a reference count of 1;
   // v4 has a reference count of 1;
end;
   // v1 has a reference count of 0;
   // v2 has a reference count of 0;
   // v3 has a reference count of 0;
   // v4 has a reference count of 0;

procedure TForm1.MyProcess1;
var
   vA, vB: IVersionInfo;
begin
   vA := TVersionClass.Create(self);

   // vA has a reference count of 1;
   // vB is unassigned;

   vB := TVersionClass.Create(self);

   // vA has a reference count of 1;
   // vB has a reference count of 1;
end;
   // vA has a reference count of 0;
   // vB has a reference count of 0;

However, if you pas an interface reference into a method as a paremeter, 
then you get this behaviour :

procedure TForm1.Button1Click(Sender: TObject);
var
   v1: IVersionInfo;
begin
   v1 := TVersionClass.Create(self);

   // v1 has a reference count of 1;

   MyProcess1(v1);

   // v1 has a reference count of 1;

   MyProcess2(v1);

   // v1 has a reference count of 1;
end;
   // v1 has a reference count of 0;

procedure TForm1.MyProcess1(aVersionInfo: IVersionInfo;
begin
   // aVersionInfo has a reference count of 2;
end;

procedure TForm1.MyProcess2(const aVersionInfo: IVersionInfo;
begin
   // aVersionInfo has a reference count of 1;
end;

Note that, passing an interface as a const parameter stops the reference 
count being incremented in a method.

Joanna

-- 
Joanna Carter [TeamB|http://www.teamb.com]
Consultant Software Engineer
0
Joanna
12/30/2008 10:03:30 AM
Joanna Carter <joanna@no.spam.for.me> wrote in news:60713
@forums.codegear.com:

> Pak Tse a écrit :
> 
>> How about I rephrase my question to ignore my previous, and the new 
>> situation as follows:
>> 
>> - IVersionInfo inherit from TInterfacedObject
> 
> Unless this is a typo, this is not possible; an interface cannot inherit
> from a class.
> 
>> - TVersionClass = class (TMyAnyClass, IVersionInfo)
> 
> However, TVersionClass should inherit from TInterfacedObject :
> 
> type
>    TVersionClass = class (TInterfacedObject, IVersionInfo)
> 
>> When I click the button1, what will be the reference count of the
>> interface "IVersionInfo":
> 
> I'm sorry but you really have got hold of the wrong idea here.
> Interfaces do not hold reference counts, it is the variables that hold
> interfaces that have reference counts.

I can only parse that last sentence in one way and doing so results in 
semantics that are wrong. So, trying extra carefully to write what I mean 
and mean what I write:

It is not the _variables_ that "have reference counts". The reference count 
is associated with the object instance of the class that implements the 
interface. The reference count is typically implemented as a private field 
of the object (but that is an implementation detail, hidden from the user 
of the interface).

For example:

type
  TSomeClass = (TInterfacedObject, ISomeInterface);

var
  v1, v2: ISomeInterface;

v1 := TSomeClass.Create;

// the object's reference count is now 1

v2 := v1;

// the object's reference count is now 2

v1 := nil;

// the object's reference count is now 1

v2 := nil;

// the object's reference count is now 0, so the object destroys itself
0
Christopher
12/30/2008 12:47:01 PM
Christopher Cheney a écrit :

> I can only parse that last sentence in one way and doing so results in 
> semantics that are wrong. So, trying extra carefully to write what I mean 
> and mean what I write:
> 
> It is not the _variables_ that "have reference counts". The reference count 
> is associated with the object instance of the class that implements the 
> interface. The reference count is typically implemented as a private field 
> of the object (but that is an implementation detail, hidden from the user 
> of the interface).

Hi Christopher, you have a good point but can I just try to make a 
slight correction?

A variable that holds an interface reference is, in fact holding an 
indirect reference to an instance of a class that implements that interface.

e.g.

type
   ISomeInterface = interface
     ...
   end;

   TSomeClass = class(TInterfacedObject, ISomeInterface)
     ...
   end;

....

var
   v1: ISomeInterface;
begin
   v1 := TSomeClass.Create;

At this point, v1 holds an indirect reference to an instance of 
TSomeClass, and that instance contains an integer field that has been 
incremented from 0 to 1, as a result of assigning that instance to the 
var v1.

So, although you are semantically correct in saying that variables do 
not have reference counts, in effect, because the variables can hold the 
instance that contains the reference count, then a variable that holds 
an interfce reference can be said to hold either nil or an instance 
which will have a reference count.

Now, has that covered all bases or simply served to confuse further :-)

> For example:
> 
> type
>   TSomeClass = (TInterfacedObject, ISomeInterface);
> 
> var
>   v1, v2: ISomeInterface;
> 
> v1 := TSomeClass.Create;
> 
> // the object's reference count is now 1
> 
> v2 := v1;
> 
> // the object's reference count is now 2
> 
> v1 := nil;
> 
> // the object's reference count is now 1
> 
> v2 := nil;
> 
> // the object's reference count is now 0, so the object destroys itself

Good simple example.

Joanna

-- 
Joanna Carter [TeamB|http://www.teamb.com]
Consultant Software Engineer
0
Joanna
12/30/2008 1:05:51 PM
Joanna Carter <joanna@no.spam.for.me> wrote in
news:60752@forums.codegear.com: 

> Christopher Cheney a écrit :
> 
>> I can only parse that last sentence in one way and doing so results
>> in semantics that are wrong. So, trying extra carefully to write what
>> I mean and mean what I write:
>> 
>> It is not the _variables_ that "have reference counts". The reference
>> count is associated with the object instance of the class that
>> implements the interface. The reference count is typically
>> implemented as a private field of the object (but that is an
>> implementation detail, hidden from the user of the interface).
> 
> Hi Christopher, you have a good point but can I just try to make a 
> slight correction?

Your post 60752: I agree. My concern was that the OP might have been 
misled by your post 60713.

Bonne annee!

Chris

> A variable that holds an interface reference is, in fact holding an 
> indirect reference to an instance of a class that implements that
> interface. 
> 
> e.g.
> 
> type
>    ISomeInterface = interface
>      ...
>    end;
> 
>    TSomeClass = class(TInterfacedObject, ISomeInterface)
>      ...
>    end;
> 
> ...
> 
> var
>    v1: ISomeInterface;
> begin
>    v1 := TSomeClass.Create;
> 
> At this point, v1 holds an indirect reference to an instance of 
> TSomeClass, and that instance contains an integer field that has been 
> incremented from 0 to 1, as a result of assigning that instance to the
> var v1.
> 
> So, although you are semantically correct in saying that variables do 
> not have reference counts, in effect, because the variables can hold
> the instance that contains the reference count, then a variable that
> holds an interfce reference can be said to hold either nil or an
> instance which will have a reference count.
> 
> Now, has that covered all bases or simply served to confuse further
> :-) 
> 
>> For example:
>> 
>> type
>>   TSomeClass = (TInterfacedObject, ISomeInterface);
>> 
>> var
>>   v1, v2: ISomeInterface;
>> 
>> v1 := TSomeClass.Create;
>> 
>> // the object's reference count is now 1
>> 
>> v2 := v1;
>> 
>> // the object's reference count is now 2
>> 
>> v1 := nil;
>> 
>> // the object's reference count is now 1
>> 
>> v2 := nil;
>> 
>> // the object's reference count is now 0, so the object destroys
>> itself 
> 
> Good simple example.
> 
> Joanna
>
0
Christopher
12/30/2008 1:46:25 PM
Christopher Cheney a écrit :


> Bonne annee!

Merci, à toi aussi :-)

Joanna

-- 
Joanna Carter [TeamB|http://www.teamb.com]
Consultant Software Engineer
0
Joanna
12/30/2008 1:50:21 PM
Pak Tse wrote:

> - TVersionClass = class (TMyAnyClass, IVersionInfo)

TVersionClass = class(TInterfacedObject, IVersionInfo)

The class that implements the interface must descend from
TInterfacedObject.

-- 
Bill Todd (TeamB)
0
Bill
12/30/2008 4:00:29 PM
>> I'm sorry but you really have got hold of the wrong idea here.
>> Interfaces do not hold reference counts, it is the variables that hold
>> interfaces that have reference counts.
>
> I can only parse that last sentence in one way and doing so results in
> semantics that are wrong. So, trying extra carefully to write what I mean
> and mean what I write:
>
> It is not the _variables_ that "have reference counts". The reference 
> count
> is associated with the object instance of the class that implements the
> interface. The reference count is typically implemented as a private field
> of the object (but that is an implementation detail, hidden from the user
> of the interface).
>
> For example:
>
> type
>  TSomeClass = (TInterfacedObject, ISomeInterface);
>
> var
>  v1, v2: ISomeInterface;
>
> v1 := TSomeClass.Create;
>
> // the object's reference count is now 1
>
> v2 := v1;
>
> // the object's reference count is now 2
>
> v1 := nil;
>
> // the object's reference count is now 1
>
> v2 := nil;
>
> // the object's reference count is now 0, so the object destroys itself


So the 'reference count' means:
The number of 'variables' are currently 'pointing' to the instance which 
implements the interface?
eg
 var
  v1, v2, v3, v4, v5 : ISomeInterface;

 v1 := TSomeClass.Create;
v2 := v1;
v3 := v2;
v4 := v1;
v5 := v3;

So the reference count of the instance implements TSomeClass is 5?
0
Pak
12/30/2008 10:15:27 PM
Pak Tse a écrit :

> So the 'reference count' means:
> The number of 'variables' are currently 'pointing' to the instance which 
> implements the interface?
> eg
>  var
>   v1, v2, v3, v4, v5 : ISomeInterface;
> 
>  v1 := TSomeClass.Create;
> v2 := v1;
> v3 := v2;
> v4 := v1;
> v5 := v3;
> 
> So the reference count of the instance implements TSomeClass is 5?

You've got it! :-)

Joanna

-- 
Joanna Carter [TeamB|http://www.teamb.com]
Consultant Software Engineer
0
Joanna
12/31/2008 12:16:54 AM
>> So the 'reference count' means:
>> The number of 'variables' are currently 'pointing' to the instance which
>> implements the interface?
>> eg
>>  var
>>   v1, v2, v3, v4, v5 : ISomeInterface;
>>
>>  v1 := TSomeClass.Create;
>> v2 := v1;
>> v3 := v2;
>> v4 := v1;
>> v5 := v3;
>>
>> So the reference count of the instance implements TSomeClass is 5?
>
> You've got it! :-)

This leads me to another question:
What if I have 2 instantiation of same class?
eg.
var
  v1, v2, v3, v4, v5,
  vA, vB : ISomeInterface;

begin
  v1 := TSomeClass.Create;
  v2 := v1;
  v3 := v2;
  v4 := v1;
  v5 := v3;

  vA := TSomeClass.Create;
  vB := vA;
  .......
end;

What will be the reference count of that interface? Or
What will be the reference count of 2 instances that implement TSomeClass?
0
Pak
1/1/2009 10:27:31 PM
Each instance of the class maintains its own reference
count. Put another way, the reference count for any
instance of a class that implements an interface will equal
the number of interface variables that point to that
instance of the class.


-- 
Bill Todd (TeamB)
0
Bill
1/1/2009 10:55:12 PM
> Each instance of the class maintains its own reference
> count. Put another way, the reference count for any
> instance of a class that implements an interface will equal
> the number of interface variables that point to that
> instance of the class.

Thanks Bill.
I think I got the meaning of reference count now. It means the number of 
interface variables as you pointed out.
0
Pak
1/7/2009 5:57:32 AM
Reply:

Similar Artilces:

Interface reference counting...
Normally I'm used to manage correctly the interfaces and related reference counter. Today I need to bypass the native system and get an interface without increment the reference counter. Unfortunately I isn't able to understand if this code could work fine, but if you have any suggestion PLEASE help me ;) .... ... FChannels: TInterfaceList; ... .... function TBridgeManager.GetChannel(ChannelIndex: Integer): IBridgeChannel; var P: Pointer; begin if (ChannelIndex< 0) or (ChannelIndex> FChannels.Count) then begin Result := nil; Exit; ...

interface reference counting #2
Never used interfaces before and have been playing with a little test program to understand how they work. I've defined an interface & an implementing class. /////////////////////////////////// unit Thing; interface type ICanDoStuff = interface ['{E1CC74CA-85DD-49A3-9A77-30FC4BCECA83}'] function DoStuff:String; end; TMyThing = class(TInterfacedObject, ICanDoStuff) function DoStuff:String; end; implementation function TMyThing.DoStuff; begin Result:='DoStuff!'; end; end. ////////////////////////// Then,...

How to implement interface reference counting on TInterfacedPersistent?
Hi, I am trying to implement interface reference on TInterfacedPersistent. I know that TInterfacedPersistent uses an 'external' interface to do the actual reference counting but this needs to inherit from TPersistent (from the method TPersistent.GetOwner). This to me seems to be a bit of a chicken and the egg situation. Would I be correct in saying that I would have to implement reference counting (the methods QueryInterface, _AddRef and _Release) on a TPersistent? If that is the case, I do not quite understand that the point is of TInterfacedPersistent. I would be most...

Reference Counting and Object Harvesting in Delphi
nice article! http://www.drdobbs.com/mobile/reference-counting-and-object-harvesting/240155664?pgno=1 Ralf Stocker wrote: > nice article! Wait -- more good press! Awesome! -- Nick > nice article! Article or an ad? See the authors... "John Ray Thomas is the Director of Project Management and Marco Cantu is the Delphi Product Manager at Embarcadero." > {quote:title=Luigi Sandon wrote:}{quote} > > nice article! > > Article or an ad? See the authors... > > "John Ray Thomas is the Director of Project Management and Marco Ca...

Weak interface references in earlier versions of Delphi
Hi, I am working on component which need to be supported in earlier version of Delphi (starting from Delphi 6) and I have problem with reference counting of interfaces. Last days I am trying to learn more about this topic, and I have collected this info: - XE2 (or maybe XE3) include [weak] attribute, but I need to support very old Delphi 6. - At few places I have read that if I declare variable as pointer, RefCount will not be incremented. There are some traps with this approach (which I already discovered :( ), but it seems that this approach work when I assign value. But, as soon I...

DP Delphi-Reference, Meta-Searchengine for Delphi
Hi *.*, I have just revived an old project, a meta-searchengine for Delphi: http://ref.dp200x.de it searches simultaneous: * delphi 2009 online-help hosted by embarcadero * msdn-library psdk (win32) * delphi-praxis codelibrary: ready-to-use code-snippets from one of germanys largest delphi-communities * delphi-praxis forums This project is still in progress and particularly help-content from delphi 2010 is (yet) missing. Content from MSDN needs to be complemented (expanded). Anyway - I think that searching the reference(s) AND realworld-examples in just a single click gi...

delphi.general
Sorry if this is "out of topic"! but since some days ago I can't read the group *embarcadero.public.delphi.language.delphi.general* Does anybody know if there's something wrong with it? Or maybe is my reader? (Thunderbird) I get this messagge when I try to read the latest messages: Error! newsgroup server responded:no such article found Perhaps the article has expired <692702@forums.embarcadero.com> (33145) Click here to remove all expired articles sergio wrote: > Sorry if this is "out of topic"! but since some days ago I can'...

To Reference or not to reference
I've written a Perl program that declares a hash at the top of the program "%myHask;". It has worked great until now when one sub program seams to be making its own copy of the hash. I can find no typo's or anything but there my still be one there. My question is would it be better to pass the global hash by reference to each sub program to cut down on possible typo errors or just leave it global and fix the problem I have? Don Dukelow On 3/29/07, Dukelow, Don <don.dukelow@hp.com> wrote: > I've written a Perl program that declares a hash at the top...

What generals generally do
Reading a McChrystal thread elsewhere, I came across someone quoting a US general http://en.wikipedia.org/wiki/Smedley_Butler > I spent 33 years and four months in active military service and > during that period I spent most of my time as a high class thug for > Big Business, for Wall Street and the bankers. In short, I was a > racketeer, a gangster for capitalism. I helped make Mexico and > especially Tampico safe for American oil interests in 1914. I helped > make Haiti and Cuba a decent place for the National City Bank boys to > collect revenues in. I ...

To Reference or not to Reference?
  My questions are numbered in bold for easier answering... I'm taking over an existing asp.net web app and have a question on references. When I right-click the web project and check the property pages, there are several dll references listed, some with a type BIN and others with a type GAC. 1) Why are some of listed in the web.config but others aren't? All the referenced dlls physically exist in the bin folder, including some third-party controls as a GAC type. I removed those GAC references, thinking they weren't needed because they physically exist in the bin fol...

Reference counting
Why does the following code leak memory? void leak() { ENTER; SAVETMPS; SV* node_var = get_sv("main::SOMETHING", TRUE); save_item(node_var); SV* obj_ref = sv_setref_iv(newSV(0), "My::Package", 0xdeadbeef); SvSetSV(node_var, obj_ref); SvREFCNT_dec(obj_ref); /* do stuff */ FREETMPS; LEAVE; } I run that in a while(1) loop and it leaks memory like crazy. I originally didn't have the SvREFCNT_dec() in there, because I thought SvSetSV would take ownership of the source SV, but I was wrong. It tries to be a value copy...

change 0211112222 to +64211112222 (Index and count must refer to a location within the string. Parameter name: count)
 Hi, Hope I can get my problem solved here. I have a mobile number which got from textbox (textbox1.text) like 0211112222. Now I need to change the format of this number to +64211112222 (add +64 in the front and remove the '0' before the first '2'). Then I wrote something like this...  "+64" & Textbox1.Text.Remove(0, 1) I got the following error: Index and count must refer to a location within the string. Parameter name: count The textbox is empty when you are running your function.  Add something like this: if (TextBox1.Text.Length >...

Interface Reference Error
The following piece of code is in a VB file IZipCode.VB that is in the App_Code directory.Public Interface IZIPCode ReadOnly Property ZIPCode() As String End Interface  It is referenced in a user control by the following: <%@ Implements Interface="IZIPCode" %> When I run the page that has the user control on it, I get the following error message: Parser Error Message: Could not load type 'IZIPCode'.Source Error: Line 1: <%@ Control Language="VB" ClassName="ZIPCodePart" %> Line 2: <%@ Implements Interface=&qu...

Invalid Interface reference
I use an interface to provide some functionality to another class/module. During shutdown of my application, the original object/form is destroyed beofre the module with the interface reference. How should I solve this problem? There may exist several TBSShapeUI objects using the TFViewMap. And since these objects are created dynamically I have not full control about the destroy order. cu Christian Here are the fragments of my code: type IBSShapeViewMap = interface // some methodes end; TBSShapeUI = class(TDataModule) strict private FViewMap : IBSShapeViewMa...

Web resources about - Interface reference counting - embarcadero.delphi.general

Interface - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

iOS 9 How-To: Use the updated multitasking interface on iPhone and iPad
Ever since Apple made the move to a more ‘flat’ design with iOS 7 , the multitasking interface has changed in either a minor or major way with ...

Google streamlining Hangouts on the web with interface tweaks, higher quality video
Google has announced some updates coming to Hangouts video calls on the web, including a tweaked interface, along with faster, crisper full-screen ...

Dictionary.com Dictionary & Thesaurus goes 7.0 with interface improvements
... especially for longtime users of the app like me. Fortunately, here comes version 7.0 of the app to the rescue with a handful of welcome interface ...

Disney CEO & Apple board member Bob Iger calls Apple TV best television interface ever
... Executive Bob Iger said in an interview on Monday, praising Apple for creating what he believes is the most intuitive television user interface ...

Firefox 43 adds new block list, updates Android user interface
Mozilla has rolled out Firefox 43 FINAL for Windows, Mac and Linux, with Firefox 43 for Android due to follow imminently. The desktop build ...

Google Updates Search Interface For Tablets
It looks like Google updated the search interface for tablets and switched to the mobile UI. The previous tablet interface was an interesting ...

Day of the Tentacle Remastered's slick interface works flawlessly
When we learned at the PlayStation Experience keynote that Day of the Tentacle Remastered was releasing March 2016, I wrote that it had been ...

Google Camera Receiving Update for Android 6.0+ Devices, Includes New Interface
Google Camera , Mountain View’s in-house shooter software for Android devices, is receiving an update to build 3.1. Inside, the new UI that is ...

Collaborative User Interface From 'Minority Report' Is Here Today
NEWS ANALYSIS: The computer user interface as seen in the movie "Minority Report"—the ultimate in collaborative environments—is available now, ...

Resources last updated: 12/26/2015 11:52:15 AM