Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8077485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T15:29:18+00:00 2026-06-05T15:29:18+00:00

Recently, I was writing a class in which I discovered that I could reduce

  • 0

Recently, I was writing a class in which I discovered that I could reduce memory consumption of instances by ~10 bytes/element, but only at the cost of making the code much more complex. This increased the size of the compiled .class file by ~10KB.

I assume that the JVM has to load the .class file into memory, so these changes wouldn’t pay for themselves unless there were at least 1000 elements or so. But that arithmetic doesn’t work out unless the extra 10KB in the class file is the only cost of the increased code complexity.

This Oracle blog suggests that there’s a fair amount of extra memory getting consumed by the class in the permgen that isn’t just based on the .class file — for example, I suspect that more complex code might require more memory for optimization metadata.

So, this question has two parts:

  • How can I measure the actual permgen memory consumption of a particular class? Either at runtime with some instrumentation, or with profiling tools?
  • Is there a way to estimate the permgen memory consumption of the class as I’m writing it? (With some background knowledge, you can estimate the memory consumption of class instances as you’re writing them; I’m wondering if we can estimate the permgen memory consumption of the class itself.)

Similar details for the Dalvik VM would be appreciated, but I’m mostly focused on OpenJDK and the other “mainstream” JVMs.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T15:29:19+00:00Added an answer on June 5, 2026 at 3:29 pm

    How can I measure the actual permgen memory consumption of a particular class? Either at runtime with some instrumentation, or with profiling tools?

    One approach could be to load the class to measure in a different classloader and use jmap -permstat as presented in this blog entry.

    For each class loader object, the following details are printed:

    1. The address of the class loader object – at the snapshot when the utility was run.
    2. The number of classes loaded (defined by this loader with the method(java.lang.ClassLoader.defineClass).
    3. The approximate number of bytes consumed by meta-data for all classes loaded by this class loader.
    4. The address of the parent class loader (if any).
    5. A “live” or “dead” indication – indicates whether the loader object will be garbage collected in the future.
    6. The class name of this class loader.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently wrote a DLL in C# (.Net 2.0) which contains a class that
I recently found myself writing a piece of code that executed a Core Data
I just recently found myself writing this line of code, which i did not
Recently, I started writing a program to compare DNA sequence. As the alphabet only
I'm writing a script that gets the most recently modified file from a unix
Recently, I've begun writing my own PHP OpenID consumer class in order to better
I recently read that in StringWriter and StringReader are used for writing and reading
Recently, I have been writing many classes which have, apart from generic variant, some
So I am recently writing a relatively complex application written in C# that performs
In writing a class recently, I initially included a __repr__ method along the following

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.