There's no sizeof operator like in C, if that's what you mean. Java tries to abstract you from the idea of the physical memory. However, if you use a profiler like OptimizeIt, you can get some idea of how many objects of each type have been allocated, and how much memory they take. On the other hand, if you meant how to get a count of the attributes currently contained in a session (and you're talking about an HttpSession), I don't see an obvious way. You have to getAttributeNames(), then cycle through the Enumeration to count them.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com