How to inspect area where methods are stored in Java Virtual Machine

Questions

  1. Where is the method for my object stored ?
  2. and can I see that area if I dump my java app ?

Background

I'm trying to measure the size of my object and realize that methods are not stored in the same place as the object data.

I'm trying to 'see' where the code for the methods are stored in a running Java app.

I tried dumping the heap using jmap and inspecting the dump using jhat, but I can't find anything useful regarding where the methods for my classes are.

Answers


Where is the method for my object stored

They are stored within a Class object, which is kept in PemGen space.

and can I see that area if I dump my java app ?

This is not trivial. JVM performs several optimizations like JIT compiling which makes this task harder.

I'm trying to 'see' where the code for the methods are stored in a running Java app.

You are aware that there is just a single copy of every method per class, not per instance? This means that once the class is loaded by the ClassLoader, all methods of that class are stored in memory. It doesn't matter how many instances you create. That being said, you probably don't care how much memory do methods consume.

See also:

Need Your Help

OpenSceneGraph Sphere Geometry (not Geode) generation

3d geometry openscenegraph

I am very bad at OSG. I can make Sphere with Geode.

Is it possible to pass a line of css coding into less as a variable?

css twitter-bootstrap less media-queries

I am trying to create a system that will output different font sizes and line heights for every different media query, in doing so I've been faced with a problem. Any help would be very much apprec...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.