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

  • Home
  • SEARCH
  • 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 8163211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:58:04+00:00 2026-06-06T18:58:04+00:00

When running java -javaagent:ObjectSizeFetcherAgent.jar PersistentTime I get 24 when ObjectSizeFetcherAgent does this public class

  • 0

When running

java -javaagent:ObjectSizeFetcherAgent.jar PersistentTime

I get

24

when ObjectSizeFetcherAgent does this

public class ObjectSizeFetcher {
    private static Instrumentation  instrumentation;

    public static void premain(String args, Instrumentation inst) {
        instrumentation = inst;
    }

    public static long getObjectSize(Object o) {
        return instrumentation.getObjectSize(o);
    }
}

and when PersistentTime looks as follows

public class PersistentTime {

    List<String>    list    = new ArrayList<String>();

    public static void main(String[] args) {

        PersistentTime p = new PersistentTime();

        p.list.add("a");  // The number is the same with or without this
        p.list.add("b");  // The number is the same with or without this
        p.list.add("c");  // The number is the same with or without this

        System.out.println(ObjectSizeFetcher.getObjectSize(p));
    }
}

Why is adding elements to the list have no affect?

  • 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-06T18:58:05+00:00Added an answer on June 6, 2026 at 6:58 pm

    Your PersistentTime object consists solely of one reference (to an array list).

    24 bytes is typical for objects containing a single reference.

    Note: referenced objects are not included in the computation. getObjectSize is not recursively collecting the combined object sizes. This is not generally possible: there could be infinite reference loops and such; I don’t think there is a “deep size” computation easily available.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Running Apache/PHP on this PC. I am using Eclipse >> Export Java > JAR
Someone where i work noticed (in stacktrace) that when running the jvm with -javaagent:spring-instrumentation.jar
I'm making a tool to dynamically display the sourcecode of running java class. I
I feel that this is something I should know, but does a java agent
I'm running Java Server Faces on a IBM WebSphere 6.1. I'm getting this strange
How can I make available ojdbc14.jar on running java command?
i've got exception, while running java class from Eclipse: java.util.MissingResourceException: Can't find bundle for
java.lang.ClassNotFoundException: com.hazelcast.core.Hazelcast This bit is strange though, because i've added hazelcast-1.8.5.jar to the classpath
We're running Java Swing and are using an SWT bridge to get ahold of
Please correct me if I am wrong. When running java [-options] -jar jarfile with

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.