Instance size

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ramona van Riet

    #1

    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
  • Stephane Rodriguez

    #2
    Re: Instance size

    Doesn't Marshal.SizeOf( ...) works for you?


    "Ramona van Riet" <RamonaVanRiet@ hotmail.com> wrote in message
    news:bgql39$icv $04$1@news.t-online.com...[color=blue]
    > 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[/color]


    Comment

    • Scott

      #3
      Re: Instance size

      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:


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


      Comment

      • Ramona van Riet

        #4
        Re: Instance size

        Stephane Rodriguez wrote:
        [color=blue]
        > Doesn't Marshal.SizeOf( ...) works for you?[/color]

        It doesn't work on managed reference types, like my own classes.
        --
        Ramona

        Comment

        • Ramona van Riet

          #5
          Re: Instance size

          Scott wrote:
          [color=blue]
          > 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.[/color]

          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

          Comment

          Working...