Our application have a thread pool
Now, we want to know while serving the request, how much memory the thread is consuming
Is there any way to find it out
Joined: Apr 13, 2009
The standard text-book answer:
1. The only memory a thread definitely owns is its stack (not sure how much).
2. Threads share the same process space (heap), so as far as I know it's not really feasible to answer this question.
Could be wrong, though.
Edit: I mean, I understand what you're asking but effectively you'd have to trace through all of the references and somehow consider the fact that some objects are accessible to more than one thread.
What sort of objects are your threads referencing? Does it have some sort of collection?
Joined: Nov 13, 2006
Thanks for your reply
Yes you are right that its not really feasible to answer this question
Actually I was just looking whether there is any API or in built feature in JDK's latest releases, but there is nothing of that sort
And also we cannot trace all the references as local variables are also allocated on STACK, which can be GCed after completion of methods.