1

I am planning to migrate to Java 8, before I want to check how many classes are being loaded in my project, and more important how much space they will take, so that I can tune and configure metaspace accordingly.

I know that I can use jstat for this purpose, but not sure what kind of parameters do I need to get the result I want.

  • 2
    Why do you assume that you'll need to tune the metaspace? It grows as needed by default. – Marko Topolnik Feb 18 '15 at 10:41
  • Class metadata allocation is limited by amount of available native memory, so I want to limit the amount of native memory based on the amount of classes I have. –  Feb 18 '15 at 10:45
  • 2
    But the JVM won't just keep allocating metadata of random classes; the only problem you may encounter is with an application which constantly creates new classes and disposes of old ones. This is not a normal scenario by any account. – Marko Topolnik Feb 18 '15 at 10:48
  • Thanks for info, I will keep this into account. –  Feb 18 '15 at 11:03
  • 2
    For example, if you have JEE application container or Tomcat, and you often redeploy applications without restarting the JVM process, that may be a case where you need to control metaspace size. – Marko Topolnik Feb 18 '15 at 11:06

2 Answers2

1

You should use some java profiler tool. Here are some of them link. YourKit is really decent but its not free.

Milkmaid
  • 1,659
  • 4
  • 26
  • 39
1

Use jconsole / jvisualvm from the bin of jdk. Its more intuitive and informative.

Kedar Parikh
  • 1,241
  • 11
  • 18