Size of objects with multiple interfaces

I have a generic object class, that implements different interfaces:

TBSItem = class(TInterfacedObject, IBSMapSelectable, IBSCommentOwner, IBSFileOwner, IBSEditable)
private
  FValue : Integer;
end;

If I create such objects, how much memory do they use? 

For a record it would just be the four bytes for an integer, but how is it for an object? And does
adding an interface increase the size of each object instance?

cu Christian
0
Christian
7/30/2015 7:49:57 AM
embarcadero.delphi.win32 2183 articles. 0 followers. Follow

5 Replies
403 Views

Similar Articles

[PageSpeed] 7

> {quote:title=Christian Kaufmann wrote:}{quote}
> I have a generic object class, that implements different interfaces:
> 
> TBSItem = class(TInterfacedObject, IBSMapSelectable, IBSCommentOwner, IBSFileOwner, IBSEditable)
> private
>   FValue : Integer;
> end;
> 
> If I create such objects, how much memory do they use? 
> 
> For a record it would just be the four bytes for an integer, but how is it for an object? And does
> adding an interface increase the size of each object instance?
> 
> cu Christian

Each interface supported by a class adds a pointer field to an object instance, that is 4 bytes for 32-bit compiler, 8 bytes for 64-bit compiler. Negligible in 99% cases.
0
serg
7/30/2015 3:10:49 PM
Christian Kaufmann wrote:

> I have a generic object class, that implements different interfaces:
> 
> TBSItem = class(TInterfacedObject, IBSMapSelectable, IBSCommentOwner,
> IBSFileOwner, IBSEditable) private
>   FValue : Integer;
> end;
> 
> If I create such objects, how much memory do they use?

The size of TInterfacedObject plus an integer sized field plus a
pointer sized field for each interface supported. As soon as my website
is up again, you can see it in my article on pointers.

-- 
Rudy Velthuis        http://www.rvelthuis.de

"The world is divided into people who think they are right."
 -- Unknown
0
Rudy
7/30/2015 3:31:34 PM
Christian Kaufmann wrote:

> I have a generic object class, that implements different interfaces:
> 
> TBSItem = class(TInterfacedObject, IBSMapSelectable, IBSCommentOwner,
> IBSFileOwner, IBSEditable) private
>   FValue : Integer;
> end;
> 
> If I create such objects, how much memory do they use?

The size of TInterfacedObject plus an integer sized field plus a
pointer sized field for each interface supported. As soon as my website
is up again, you can see it in my article on pointers.

-- 
Rudy Velthuis        http://www.rvelthuis.de

"The world is divided into people who think they are right."
 -- Unknown
0
Rudy
7/31/2015 6:51:21 AM
Christian Kaufmann wrote:

> I have a generic object class, that implements different interfaces:
> 
> TBSItem = class(TInterfacedObject, IBSMapSelectable, IBSCommentOwner,
> IBSFileOwner, IBSEditable) private
>   FValue : Integer;
> end;
> 
> If I create such objects, how much memory do they use? 

See here (temporary URL until my normal site is up again):

http://praxis-velthuis.de/rdc/articles/articles-pointers.html#interfaces

-- 
Rudy Velthuis        http://www.rvelthuis.de

"An intellectual is someone who has found something more
 interesting than sex." -- Edgar Wallace.
0
Rudy
8/1/2015 11:38:33 PM
>See here (temporary URL until my normal site is up again):
>
>http://praxis-velthuis.de/rdc/articles/articles-pointers.html#interfaces

Thanks, this is nice. Just wondering why not more such easy to understand articles about these kind
of topics can be found on the Embarcadero website...

Maybe I get old and it's just obsolete to be interested in such information.

cu Christian
0
Christian
8/3/2015 5:34:24 AM
Reply:

Similar Artilces:

Multiple Interface on same object
Hello All, I want to gain access to an ole server with PB 6.0. This server have multiple interfaces on the objects. How is it possible to have access to the alternate interfaces. This is currently done by QueryInterface (QI) if you use c++ or by simple assignement if you use Visual Basic. All interfaces are OLE Automation and inherit from IDispatch. Thank you to email your answer as well. Bruno Winck bwinck@radialsoft.com http://www.radialsoft.com/ CADCAM Connection point Bruno, Did you ever figure out how to do this? My company makes a set of ActiveX components whi...

Making a Mashup between Objects in Multiple Interfaces.
Hi, I'm wondering how best to do something to keep client coding easy. Currently I have a set of webservices. e.g. IPerson (which has method calls to add, update, search etc) I also have ICheckLists (which has lists of elements that people (and other objects) subscribe too) Different interfaces very loosely coupled. What I want to do is make a Search for people within certain lists. The problem I have is that if I declare IPersonIntf or ICheckListIntf objects into the other implementation, I then end up with two declarations of the same object, with the same URN but in ...

[Discussion] My Wishlist on interface in Delphi for Win32
*1. Supports generic method* There are so many scenarios for using generic method insteading of generic interfaces, such as: ILogger = interface procedure Info(const msg: string); procedure Info<T>(const obj: T); //... end; or, // Reprensents a IoC container IUnityContainer = interface procedure RegisterType<TType, TImplementation>; function Resolve<T>: T; //... end; As you can see, Generic Interfaces are obvious not suitable in these cases. I really have no idea why delphi doesn't support it. *2. Determines whether a object suppor...

Does powerbuilder support multiple interface com object?
Greetings, Anybody has any idea on this one? Is there any workaround for that? We need to interface our existing PB application developed on PB 7.03, win 2000 with GIS com object.. But the problem how to get the interface other than Idispatch in PB. Thanks Raman Chawla AFAIK - it doesn't. Just to be sure, have a look at the component properties via the OLE tab on the PB object browser -- do you see any of the methods exposed by the 2nd interface? If not, the workaround would be to use a wrapper COM object that exposes all functionality through a single inte...

Does powerbuilder support multiple interface com object?
Greetings, Anybody has any idea on this one? Is there any workaround for that? We need to interface our existing PB application developed on PB 7.03, win 2000 with GIS com object.. But the problem how to get the interface other than Idispatch in PB. Thanks Raman Chawla ...

Does powerbuilder support multiple interface com object?
Greetings, Anybody has any idea on this one? Is there any workaround for that? We need to interface our existing PB application developed on PB 7.03, win 2000 with GIS com object.. But the problem how to get the interface other than Idispatch in PB. Thanks Raman Chawla ...

Using Sharepoint client objects from Delphi win32 fails
Hi, Really nice if someone could help use with this .NET assembly access problem! We have a problem of accessing Sharepoint Client objects from our win32 Delphi application (Document management), developed in Delphi XE. We have built a .NET COM assembly that encapsulates the Sharepoint Client objects and we generate a pascal TLB from this, our .NET assembly. Calls that are not routed to the Sharepoint Client objects work, but immediatelly when trying to get access to Sharepoint Client Objects, through our .NET COM assembly there seems to be a exception loop started within the Sharepoi ...

multiple inheritance problem when interfacing C++ object in perlX S
Hi, I have some object with multiple inheritance : class D : public B1, public B2 B1 B2 \ / D I made XS interface for B1,B2 and D classes, and I set ISA to match inheritance in the perl packages I have a function that have parameters from type B2 and I want to pass a D to this function. int func(B2* obj1,B2* obj2){ return obj1 == obj2; } D* d_ptr = new D(); B2* b2_ptr = dynamic_cast<B2*>(d_ptr) func(d_ptr,b2_ptr); >> return true this works fine in full C++ but in the XS mapping the following process is in action: D* object i...

BUG DELPHI 2009 Win32: Interfaces are not always NIL in records [Edit]
Wanting to confirm this is a bug. Snip the program below, compile and run: ============================== program ArrayBug; {$APPTYPE CONSOLE} uses SysUtils, Classes; Type IMyInterface = Interface End; PRec = ^MyRec; MyRec = record private fInterface : IMyInterface; i : integer; Type TMyInterface = class(TInterfacedObject, IMyInterface) private pVal : PRec; protected function GetValue : integer; public constructor Create(const aRec : PRec); overload; destructor Destroy; override; ...

Lifespan of interface objects for shared objects
our Server has shared objects that are referenced through interface objects that are in turn accessed by the client app. When the client app does the CreateInstance call, a interface object on the server is created, we have the SharedObjectGet() call in the constructor of the interface object. The functions on the interface object just map to functions on the shared object. - E.G. pretty standard way of doing things Our question is the management of the server memory and scope of the server interface objects that were instantiated by the client's call of CreateInstance. 1) Is t...

Object file size limit / Object Cycle
Hi Gurus, What's the maximum file size allowed for an object in Object Cycle? When trying to register a new object I'm getting this message: "The client does not have permission to send this request to the Object Cycle service Error 809-0" The only difference I can report is that the file size is > 1000 Kb. What we are doing is keeping versions of the pbls (zipped), not every pb object. TIA VM Did anyone have a response to this? We're seeing the same behavior. Object Cycle Server is Windows 2000 Server and clients are Windows 2000 Professi...

Migrate from Delphi 2007 for Win32 to Delphi XE
we use Delphi 2007 for Win32 to support legacy (32Bit) OWL-based pascal applications (yes i know it was a mistake not to switch to VCL 15 years ago). could our applications still be opened and compiled with Delphi XE? The existing projects are all plain Pascal-Code, coming back from the times of Turbo Pascal for Windows and later on Borland Pascal. Are there any improvements we could profit from (i.e IDE, Debugger)? Thanks Andrej > {quote:title=Andrej Dimic wrote:}{quote} > could our applications still be opened and compiled with Delphi XE? I'm not sure, but I guess ...

Delphi.NET loading Delphi.Win32 Driver
Hi, What I'm trying to do is marshal an array of cardinal (or integer) back into managed memory from a win32 dll. I know how to pass managed memory into a win32 dll {code} var aa : array of Integer; Buffer : IntPtr; begin SetLength(aa,2); aa[0] := 1; aa[1] := 80; if not Supports(ExtractFilePath(Application.ExeName)+'Win32_Library\SDK_Driver.Win32.io', TypeOf(IMyFunctions), MyFunctions) then Exit; //loads the driver into memory. MyFunctions contains the method names found in the SDK_Driver. Buffer := Marshal.AllocHGlobal(2 * {Marshal.SystemDefaultC...

treating multiple objects matching other multiple objedts.
Hi,=20 The follow is a script I wrote designed to send mail messages with = predefined attachments, as an alerts coming from Big Brother system.=20 That is how it works: As soon as mail arrives from Big Brother, files = named "down" & "up" generated by a .procmailrc file. The down & up files = are trigger files that once exists, generate a mail massage with the = predefined attachment (which are different for, which is specific for = each server & service (there are 23 servers & 4 services). There is a = directory tree of all servers & services...

Web resources about - Size of objects with multiple interfaces - embarcadero.delphi.win32

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

This startup wants to bring a Minority Report-style interface to your living room
... ago. After all, the best input device would be no extra input device at all—who wouldn’t want a perfectly accurate Star Trek -style voice interface ...

In pictures: iOS 9 vs. Android 6.0 Marshmallow user interfaces
Apple and Google already have hundreds of millions users for their mobile operating systems. Hardcore fans of each mobile platform seem to be ...

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

Digitimes Research: Pogo Pin to account for over 60% of power charging interfaces used in smart wearable ...
Pogo Pin will account for over 60% of power charging interfaces used in smart watches and smart bands in 2016, all types of USB together for ...

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

What are brain-machine interfaces, and how do they work?
Brain-machine interfaces seem like pure science fiction, but they're already revolutionizing medicine and your smartphone might not be far behind. ...

Resources last updated: 12/10/2015 5:14:44 AM