File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Threads and Synchronization and the fly likes How much memory thread has consumed Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Reply Bookmark "How much memory thread has consumed" Watch "How much memory thread has consumed" New topic
Author

How much memory thread has consumed

Mittal Vishal
Greenhorn

Joined: Nov 13, 2006
Posts: 21
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

Joined: Apr 13, 2009
Posts: 96
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

Joined: Nov 13, 2006
Posts: 21
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.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: How much memory thread has consumed
 
Similar Threads
max threads
Eclipse becoming soooo slowww... any tricks to speed it up?
hundreds of threads
Regarding the IText API
64KB memory