Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8490395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:06:15+00:00 2026-06-10T22:06:15+00:00

Say I have following class: Class A { B b; C c; D d;

  • 0

Say I have following class:

Class A
{
 B b;
 C c;
 D d;
}

First, I allocate:

var b1 = new B();
var c1 = new C();
var d1 = new D();

each of b1, c1, d1 is less than 85K, so they get allocated on the small object heap.
Then I do:

var a1 = new A { b = b1, c = c1, d = d1 };

Question1: When I do !DumpHeap -stat does the mem usage of A include memory occupied by its member variables? If not, what does it actually include?
EDIT: found answer to this question in this post: http://blogs.msdn.com/b/tess/archive/2005/11/25/dumpheap-stat-explained-debugging-net-leaks.aspx. It makes sense that mem usage of A does NOT include memory occupied by b1, c1, d1. It includes the memory needed to store the b1, c1, d1 references themselves.

Question2: Does a1 get allocated on the large object heap (assume size of b1 + c1 + d1 > 85K)? Why? The references b1, c1, d1 point to objects on small object heap. Then why would a1 sit on the LOH?

Question3: Lets flip it around. Say size of b1 is more than 85K, so its allocated on the LOH. But to store references to b1, c1, d1 we only need a few bytes. Am I correct in believing that a1 will be allocated on the small object heap?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T22:06:17+00:00Added an answer on June 10, 2026 at 10:06 pm

    1) As you have already found out the size of the instance of A does not include the size of the referenced objects. However, if you want to find out the size use the !objsize command. Keep in mind that if multiple objects reference the same other objects the size of these will be included multiple times.

    2) The object referenced by a1 does not get allocated on the LOH. The object itself is less than 85000 bytes, so it is allocated on the regular heap. Use the !gcwhere command to list what part of the heap a given object is in.

    3) It doesn’t matter if the b1 reference points to a large object. The size of any instance of A will only be three references plus some additional overhead (a reference to the type object and a syncblock). I.e. the size will be very far from the LOH limit.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say we have following this: <p class=first>This is paragraph 1.</p> <p class=second>This is
Say I have the following class: class User(Base): __tablename__ = 'users' id = Column(Integer,
Say I have the following class: class Foo { // ctor etc here public
Lets say I have the following class: public class Provider { ... public sealed
Let's say I have the following class hierarchy: TaskViewer inherits from ListViewer<Task> which in
Let's say I have the following class hierarchy in C++: class Base; class Derived1
Say I have the following code: class Parent { static string MyField = ParentField;
Ok say I have the following model: class Country < ActiveRecord::Base validates_presence_of :name validates_presence_of
Let's say I have the following code: class MyClass(object): def __init__(self, param): self.param =
Let's say I have defined the following class: public abstract class Event { public

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.