How much memory is used by an object?

Jacob Carlborg doob at me.com
Mon Feb 18 06:23:00 PST 2013


On 2013-02-18 13:43, Alexandr Druzhinin wrote:
> Suddenly I detect that my application is using too much memory, so I
> need some way to know how much memory is used by some object to improve
> the app. How can I do it?
> I've used some OS specific things but they aren't convenient because
> provide information about the whole application, instead of the specific
> class instance. Simple size calculation of class fields doesn't
> correspond to memory consumption.

An object will contain some hidden members as well. Try this:

http://dlang.org/traits.html#classInstanceSize

-- 
/Jacob Carlborg


More information about the Digitalmars-d-learn mailing list