I assume that you count only objects on the heap. If this is the case, you can log all calls to new and delete by replacing them with some custom macros.
We have developed such a custom logging facility. The primary purpose was to track memory leaks, but it can also be used to find out how many objects at any specific time. For example,
#define MY_NEW_OBJECT(a, T) \
a = new T; \
MY_LOGGING((LM_DEBUG, "[NEW OBJ ] 0x%08X(%s), %4d bytes. %-20s - %-40s - %4d\n", a, #T, \
sizeof(T), __FILE__, __func__, __LINE__));
MyClass* myObj;
MY_NEW_OBJECT(myObj, MyClass);
The MY_LOGGING adds timestamp automatically at the beginning of each line. The line has the class name, filename, line number, function name, and the size.
A utility parses the logging file and generates graphs showing the number of objects, total size utilized etc at any time.
Of course, you have to replace every new/delete calls with the macros. Which might be quite a bit work.