Re: How much memory do managed code objects take, really?
From: Marcos Stefanakopolus (taruntius_at_hotmail.com)
Date: 01/07/05
- Next message: Jon Skeet [C# MVP]: "Re: How much memory do managed code objects take, really?"
- Previous message: Jon Skeet [C# MVP]: "Re: How much memory do managed code objects take, really?"
- In reply to: Jon Skeet [C# MVP]: "Re: How much memory do managed code objects take, really?"
- Next in thread: Jon Skeet [C# MVP]: "Re: How much memory do managed code objects take, really?"
- Reply: Jon Skeet [C# MVP]: "Re: How much memory do managed code objects take, really?"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 7 Jan 2005 15:50:10 -0800
>> The method I usually use is to create a test program which creates an
>> empty array of hundreds of thousands of references, finds out the
>> amount of memory used, fills in the array with hundreds of thousands of
>> objects, finds out the amount of memory *then* used, and then looks at
>> the difference between the two.
And how do you do the "finds out the amount of memory used" part? Do you
have some code you could share? Somehow I doubt that what Task Manager will
tell me is either precise or accurate enough.
>> > In C++, if I build 1 WorldTriangle, I've used 12 bytes for pointers to
>> > the
>> > vertices, and 36 bytes for the vertex objects themselves. In C#, How
>> > much
>> > memory have I really used?
>>
>> Each object has an overhead of 8 bytes. Each float takes 4 bytes. Each
>> reference takes 4 bytes.
So you're saying that all reference types have an 8-byte overhead, while
value types have a 0 byte overhead? If true, that's probably sufficient for
my purposes.
> Sorry, I meant to mention - there are also potential gaps due to
> padding between elements.
Yes, I'm aware of that potential issue. Fortunately, there's
[StructLayoutAttribute(LayoutKind.Explicit)] to help with that.
- Next message: Jon Skeet [C# MVP]: "Re: How much memory do managed code objects take, really?"
- Previous message: Jon Skeet [C# MVP]: "Re: How much memory do managed code objects take, really?"
- In reply to: Jon Skeet [C# MVP]: "Re: How much memory do managed code objects take, really?"
- Next in thread: Jon Skeet [C# MVP]: "Re: How much memory do managed code objects take, really?"
- Reply: Jon Skeet [C# MVP]: "Re: How much memory do managed code objects take, really?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|