473,327 Members | 2,069 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Instance size

How can I find out what the *instance* size of an object is? I know i can
use sizeof() on value types, but using it on an objhect reference only
gives me 4, which simply means that the reference is a 4 byte pointer.

How can I find out how big the referenced object is, i.e. the total size
of all private, protected and public members and hidden members, like
virtual method tables, interface reference tables, etc.? I have browsed
the online help, but couldn't find anything yet.
--
Ramona
Nov 15 '05 #1
4 6645
Doesn't Marshal.SizeOf(...) works for you?
"Ramona van Riet" <Ra***********@hotmail.com> wrote in message
news:bg*************@news.t-online.com...
How can I find out what the *instance* size of an object is? I know i can
use sizeof() on value types, but using it on an objhect reference only
gives me 4, which simply means that the reference is a 4 byte pointer.

How can I find out how big the referenced object is, i.e. the total size
of all private, protected and public members and hidden members, like
virtual method tables, interface reference tables, etc.? I have browsed
the online help, but couldn't find anything yet.
--
Ramona

Nov 15 '05 #2
Ramona,

This has been discussed before. Someone who wanted to know the same
thing as you ended up, after many posts by other people, realizing
that it is just not possible to know the size of any class instance.
For a special class, I suppose you could build this kind of
functionality up, but there is no easy solution to getting the
equivalent of SizeOf() for reference objects.

For other ideas (besides mine which is no idea at all) do a google
search for "sizeof" and you'll come across all sorts of answers.

Scott

here's the google search I did:
http://groups.google.com/groups?as_q...&num=100&hl=en

"Ramona van Riet" <Ra***********@hotmail.com> wrote in message
news:bg*************@news.t-online.com...
How can I find out what the *instance* size of an object is? I know i can use sizeof() on value types, but using it on an objhect reference only gives me 4, which simply means that the reference is a 4 byte pointer.
How can I find out how big the referenced object is, i.e. the total size of all private, protected and public members and hidden members, like virtual method tables, interface reference tables, etc.? I have browsed the online help, but couldn't find anything yet.
--
Ramona

Nov 15 '05 #3
Stephane Rodriguez wrote:
Doesn't Marshal.SizeOf(...) works for you?


It doesn't work on managed reference types, like my own classes.
--
Ramona
Nov 15 '05 #4
Scott wrote:
Ramona,

This has been discussed before. Someone who wanted to know the same
thing as you ended up, after many posts by other people, realizing
that it is just not possible to know the size of any class instance.
For a special class, I suppose you could build this kind of
functionality up, but there is no easy solution to getting the
equivalent of SizeOf() for reference objects.

For other ideas (besides mine which is no idea at all) do a google
search for "sizeof" and you'll come across all sorts of answers.


I was afraid I'd get that answer. I'll google a bit, but what you say
confirms my expectations. :-(

Thanks for taking the time to answer my question.
--
Ramona
Nov 15 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: monkey king | last post by:
I have a given dll file(PDFCreator.dll) - probably generated by VC++. I want to use its method(PDFCreator()) in dotNet environment. It works well in WindiowsApplication, but bad in WebApplication...
18
by: Dan | last post by:
hello, I would to know if it is possible to delete an instance in an array, The following does not allow me to do a delete. I am trying to find and delete the duplicate in an array, thanks ...
1
by: zahni31 | last post by:
Hello, i currently setup a new machine with DB2 8.x ESE FP8 . The machine is a HP Proliant ML570, 14 GB RAM, 4xXeon 3.0 GHZ.... Windows 2003 Enterprise (booted with /3GB and /PAE). DB2 is...
5
by: Mariano Drago | last post by:
Hi there. How can i know how much memory is an instance taking, devided by internal instances. For examples lets say i have 2 classes, C1 and C2. C1 have an internal instance of C2 How can i know...
5
by: Greg | last post by:
Hi, I have been unable to resolve this error message: Object Ref not set to an instance of an object. The issue is that I cannot determine which object reference is causing the problem. ...
11
by: Bob | last post by:
In our new .NET web applications, we try to limit the use of SqlConnection to just one instance per page, even if there are multiple accesses to various queries. The thinking behind is that this...
6
by: Bruce | last post by:
I get this error on a line that references any control in the form_load sub: An unhandled exception of type 'System.NullReferenceException' occurred in BC785dProg1.exe Additional...
11
by: Özden Irmak | last post by:
Hello, In my VB.Net application I create a new instance of my form like : NewForm = new MyNewForm() But with this line, this new form is automatically shown. I want it to be hidden at the...
3
by: sravan_reddy001 | last post by:
here Box is an user defined class Box b; b = new Box; //b = new Box; /*b = new Box; for (int i = 0; i < 10; i++) { b = new Box; }*/ if(size==0)
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.