There is a simple C++ class
class LASet
{
public:
long int maxValue, minValue;
int _count;
set <long int> _mySet;
LASet()
{
maxValue = 0;
_count = 0;
minValue =std::numeric_limits<long int>::max();
_mySet.clear();
}
void Add(long int value)
{
if (_mySet.find(value) != _mySet.end())
return;
if (value > maxValue)
maxValue = value;
if (value < minValue)
minValue = value;
_mySet.insert(value);
_count++;
}
// some helper functions....
};
As I instantiate some objects from this class, I want to find their sizes during the runtime. So, I simply wrote the sizeof
after many cycles of the execution for each object. For example:
LASet LBAStartSet;
...
...
cout << "sizeof LBAStartSet = " << sizeof( LBAStartSet ) << '\n';
That cout
line reports only 72
for all objects means 72B, but top
command shows 15GB of memory.
I read the manual at cppreference that sizeof
doesn't work on some incomplete data types. Is my data type incomplete?
Any feedback is appreciated.