• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

How much memory thread has consumed

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic