Connecting Tech Pros Worldwide Help | Site Map

How to find a STL class size?

  #1  
Old October 31st, 2007, 07:35 PM
webinfinite@gmail.com
Guest
 
Posts: n/a
Hi,

How to find a STL class size, for example: string. I would like to
know what the size of the implementation of this class, I am not
interested in the size of its object but the class itself. There are
discussion regarding addition of all the data member of the class/
structure to find out its size, but is there a neat way to find out
class' size?

Thank you very much for your attention.

  #2  
Old October 31st, 2007, 08:05 PM
Victor Bazarov
Guest
 
Posts: n/a

re: How to find a STL class size?


webinfinite@gmail.com wrote:
Quote:
How to find a STL class size, for example: string. I would like to
know what the size of the implementation of this class, I am not
interested in the size of its object but the class itself. There are
discussion regarding addition of all the data member of the class/
structure to find out its size, but is there a neat way to find out
class' size?
What is "the size of the implementation of this class" as _opposed_
(by you) to "the size of its object"? What do you count as part of
the "implementation"? If you want to know how much memory is taken
away by an object (including the dynamic memory it allocates), there
is no "neat way" to do that, but your OS could be of some help or
you could use some OS-specific tools to see how much memory remains
available before and after the operation.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask


  #3  
Old October 31st, 2007, 08:15 PM
=?UTF-8?B?RXJpayBXaWtzdHLDtm0=?=
Guest
 
Posts: n/a

re: How to find a STL class size?


On 2007-10-31 19:26, webinfinite@gmail.com wrote:
Quote:
Hi,
>
How to find a STL class size, for example: string. I would like to
know what the size of the implementation of this class, I am not
interested in the size of its object but the class itself. There are
discussion regarding addition of all the data member of the class/
structure to find out its size, but is there a neat way to find out
class' size?
A class does not have a size since it does not exist anywhere than in
your source code. The only way to measure the size of a class would be
to count the number of characters or lines of code that is used in its
definition.

--
Erik Wikström
  #4  
Old October 31st, 2007, 08:35 PM
webinfinite@gmail.com
Guest
 
Posts: n/a

re: How to find a STL class size?


On Oct 31, 12:10 pm, Erik Wikström <Erik-wikst...@telia.comwrote:
Quote:
On 2007-10-31 19:26, webinfin...@gmail.com wrote:
>
Quote:
Hi,
>
Quote:
How to find a STL class size, for example: string. I would like to
know what the size of the implementation of this class, I am not
interested in the size of its object but the class itself. There are
discussion regarding addition of all the data member of the class/
structure to find out its size, but is there a neat way to find out
class' size?
>
A class does not have a size since it does not exist anywhere than in
your source code. The only way to measure the size of a class would be
to count the number of characters or lines of code that is used in its
definition.
>
--
Erik Wikström
I am sorry not stating my question clearly. My intention is to find
out how many memory is consumed by a class definition. What kind of OS
tool will give me such information?

  #5  
Old October 31st, 2007, 08:55 PM
Victor Bazarov
Guest
 
Posts: n/a

re: How to find a STL class size?


webinfinite@gmail.com wrote:
Quote:
On Oct 31, 12:10 pm, Erik Wikström <Erik-wikst...@telia.comwrote:
Quote:
>On 2007-10-31 19:26, webinfin...@gmail.com wrote:
>>
Quote:
>>Hi,
>>
Quote:
>>How to find a STL class size, for example: string. I would like to
>>know what the size of the implementation of this class, I am not
>>interested in the size of its object but the class itself. There are
>>discussion regarding addition of all the data member of the class/
>>structure to find out its size, but is there a neat way to find out
>>class' size?
>>
>A class does not have a size since it does not exist anywhere than in
>your source code. The only way to measure the size of a class would
>be to count the number of characters or lines of code that is used
>in its definition.
>>
>--
>Erik Wikström
>
I am sorry not stating my question clearly. My intention is to find
out how many memory is consumed by a class definition. What kind of OS
tool will give me such information?
A class definition exists only in C++ source. Once the program is
created from the source, there is no such thing as "class definition".
Perhaps it's time you acquaint yourself with the way compilers work.
It would require knowing how computers work, as well. "Inside the
C++ Object Model" by Lippman is a good book to start with.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask


  #6  
Old October 31st, 2007, 10:45 PM
bjeremy
Guest
 
Posts: n/a

re: How to find a STL class size?


On Oct 31, 2:30 pm, "webinfin...@gmail.com" <webinfin...@gmail.com>
wrote:
Quote:
On Oct 31, 12:10 pm, Erik Wikström <Erik-wikst...@telia.comwrote:
>
>
>
Quote:
On 2007-10-31 19:26, webinfin...@gmail.com wrote:
>
Quote:
Quote:
Hi,
>
Quote:
Quote:
How to find a STL class size, for example: string. I would like to
know what the size of the implementation of this class, I am not
interested in the size of its object but the class itself. There are
discussion regarding addition of all the data member of the class/
structure to find out its size, but is there a neat way to find out
class' size?
>
Quote:
A class does not have a size since it does not exist anywhere than in
your source code. The only way to measure the size of a class would be
to count the number of characters or lines of code that is used in its
definition.
>
Quote:
--
Erik Wikström
>
I am sorry not stating my question clearly. My intention is to find
out how many memory is consumed by a class definition. What kind of OS
tool will give me such information?
Well... like Erik and Victor said.. you cannot get the memory consumed
by a "class definition"... but a good tool if you are on a Linux
distribution is the Valgrind framework... among its toolsets is a
memory checker... (they have a neat profiler too)...

anyway... if you're interested, it's an open source project and can be
found at: http://valgrind.org/info/

  #7  
Old November 1st, 2007, 10:45 AM
James Kanze
Guest
 
Posts: n/a

re: How to find a STL class size?


On Oct 31, 7:26 pm, "webinfin...@gmail.com" <webinfin...@gmail.com>
wrote:
Quote:
How to find a STL class size, for example: string. I would like to
know what the size of the implementation of this class, I am not
interested in the size of its object but the class itself. There are
discussion regarding addition of all the data member of the class/
structure to find out its size, but is there a neat way to find out
class' size?
I'm afraid I don't understand the question: formally, only
objects have size, not classes. So do you want to know:

-- the actual size of the object: sizeof will give you that,
-- the total memory used by the object: this will depend
enormously on the implementation, and will probably vary
from one object to the next, or
-- the memory used by the class, independently of any
instances---this is also very, very implementation
dependent, and may also depend on which functions you use in
the class.

--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
C++ - STL usage 'Advice' ma740988@gmail.com answers 11 October 12th, 2005 08:55 AM
new, delete, STL Jon Slaughter answers 35 August 31st, 2005 09:55 AM
Alternatives to the C++ Standard Library? Steven T. Hatton answers 43 July 23rd, 2005 06:52 AM
problem with STL container and dynamic classes joetekubi@yahoo.com answers 4 July 22nd, 2005 09:54 PM