PLS HELP! - Getting object size

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • MuZZy

    PLS HELP! - Getting object size

    Hi,

    Is it ever possible to obtain an object's current size in managed memory?
    E.g. if i want to know what's the size in bytes occupied by the particular DataSet object right now
    (of cource including it's tables, constraints, reations and schemas).

    As i posted earlier the project i'm working on is experiencing dramatc memory leaks and i can't seem
    to find exactly where the problem is. I suspect that it's the DataSet derived class we are widely
    using that is causing that, but as this class is used in tons of other classes and places, i can't
    find which objects increase memory.


    Thank you,
    Andrey
  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: PLS HELP! - Getting object size

    Andrey,

    It's not really easy to determine the size of an object in memory (after
    all, an object might have references to other objects, and you have to find
    the size of those objects, also, you have to hook into the profiling API, I
    believe, to get this kind of information).

    Have you used the CLR profiler to take a look at the lifetime of your
    objects? It would be much easier, IMO to go that way.

    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard. caspershouse.co m

    "MuZZy" <leyandrew@yaho o.com> wrote in message
    news:qfSdnVeKYN 2kxI7fRVn-tA@comcast.com. ..[color=blue]
    > Hi,
    >
    > Is it ever possible to obtain an object's current size in managed memory?
    > E.g. if i want to know what's the size in bytes occupied by the particular
    > DataSet object right now (of cource including it's tables, constraints,
    > reations and schemas).
    >
    > As i posted earlier the project i'm working on is experiencing dramatc
    > memory leaks and i can't seem to find exactly where the problem is. I
    > suspect that it's the DataSet derived class we are widely using that is
    > causing that, but as this class is used in tons of other classes and
    > places, i can't find which objects increase memory.
    >
    >
    > Thank you,
    > Andrey[/color]


    Comment

    • MuZZy

      #3
      Re: PLS HELP! - Getting object size

      Nicholas Paldino [.NET/C# MVP] wrote:[color=blue]
      > Andrey,
      >
      > It's not really easy to determine the size of an object in memory (after
      > all, an object might have references to other objects, and you have to find
      > the size of those objects, also, you have to hook into the profiling API, I
      > believe, to get this kind of information).
      >
      > Have you used the CLR profiler to take a look at the lifetime of your
      > objects? It would be much easier, IMO to go that way.
      >[/color]

      Tes,i tried to use CLR Profiler, but it's running really slow under it and sometimes just freezing..
      Also, i found that for some reason profiler doesn't show references and objects correctly - in one
      case i knew that i have 10 instances of a class which were live but the map showed only two objects.

      By the way, does the profiler map's lines show the objects references?

      Also, it's weird, i see that my MDI Parent form class has a reference only to the first child form
      class, and that child class keeps references to other objects, but if i unreference the child form
      class, those objects don't disappear in the profiler map

      Comment

      • Jason Black [MSFT]

        #4
        Re: PLS HELP! - Getting object size

        I'm not sure if you can get that information directly for a given object,
        but the garbage collector class does have a static GC.GetTotalMemo ry()
        method for determing your program's overall memory usage. You can
        instrument your app to emit this information around calls where you think
        you might be creating problems (e.g. around the creation of a DataSet
        derived class, or around the times when data is added/removed from the set,
        etc.).

        "MuZZy" <leyandrew@yaho o.com> wrote in message
        news:qfSdnVeKYN 2kxI7fRVn-tA@comcast.com. ..[color=blue]
        > Hi,
        >
        > Is it ever possible to obtain an object's current size in managed memory?
        > E.g. if i want to know what's the size in bytes occupied by the particular
        > DataSet object right now (of cource including it's tables, constraints,
        > reations and schemas).
        >
        > As i posted earlier the project i'm working on is experiencing dramatc
        > memory leaks and i can't seem to find exactly where the problem is. I
        > suspect that it's the DataSet derived class we are widely using that is
        > causing that, but as this class is used in tons of other classes and
        > places, i can't find which objects increase memory.
        >
        >
        > Thank you,
        > Andrey[/color]


        Comment

        Working...