• Post Reply Bookmark Topic Watch Topic
  • New Topic

How much memory thread has consumed

 
Mittal Vishal
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

 
John Kimball
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Mittal Vishal
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
John,
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!