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 8162059
In Process

The Archive Base Latest Questions

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

I would like to better understand my application and specifically its memory footprint. I

  • 0

I would like to better understand my application and specifically its memory footprint.

I do understand the concepts of garbage-collection and I am aware, that there will always be a certain amount of dead objects in the heap, however, I would like to minimize this amount such that monitoring with JConsole (or JVisualVM) provides me with some information about the currently required (not occupied) space.

Is there any way to configure an existing garbage-collector (e.g. G1GC) in the SunVM such that (at the cost of responsiveness and runtime) the amount of dead objects in the heap is minimized?

Clarification

To be more clear about my objectives: My application is non-interactive so the memory-footprint over time is more or less the same between two runs. I want to determine the minimum required heap space and the influence, code changes have on that footprint. The output from JConsole is not really helping here because of the dead objects. I also want to know, whether my peak-memory really is an outstanding peak at one point in time or whether it is streched over time. This is why reducing the Xmx until I reach a OOME is not what gets me there.

Also: I’m talking about use during developer tests, not the use in production here. In production, througput and performance are – of course – more important than a more realistic memroy-footprint.

  • 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:37:42+00:00Added an answer on June 6, 2026 at 6:37 pm

    If you want to know the total amount of memory that your application is using you must monitor it for quite a long time. Samples of the heap at random moments of the application:

    jps -> output the pid of java process
    jmap -dump:live,format=b,file=heap.bin [pid]
    

    and then with jhat navigate the heap. There are another tools to do so.

    Doing this you will know what’s on the heap at a moment.

    Bear in mind that objects such as memory mapped files are not stored in the heap but in the memory.

    When reaching OOM try adding this, and then reading the output to see which objects are actually in the heap:

    -XX:-HeapDumpOnOutOfMemoryError
    -XX:HeapDumpPath=./java_pid<pid>.hprof
    

    To do so, enable the GC log and then use a tool such as GCViewer.

    -XX:+PrintGCTimeStamps
     -XX:+PrintGCDetails
    -verbose:gc
    -Xloggc:garbage_collector -> this set the file of the output
    

    When you talk about heap, I understand that you are talking about the tenured space. If so, you need to know the average life of objects. And follow some best practices and then do the fine tuning. Also remember that issuing a System.gc() does not guarantees that the GC is performed.

    The thing is that instances goes to young generation (eden) and when it is full a minor GC is performed. Objects that still reachable are passed to one of the two spaces called survivor. Once this is full that space is dumped into tenured. When full, a full GC executes and delete all instances that are not reachable.

    One thing you can do is to use primitives in methods. Those won’t be placed in the heap as their span of life is in the thread stack.

    The useful parameters are those which tie the size of the tenured and young generation (eden). These works by ratios. If you are to issue many GC bear in mind to set a max time for GC stop.

    Some interesting parameters are:

    -XX:MinFreeHeapRatio=  
    -XX:MaxHeapFreeRatio=  
    -XX:NewRatio=
    -XX:SurvivorRatio
    

    For example, setting -XX:NewRatio=3 means that the ratio between the young and old generation is 1:3; in other words, the combined size of eden and the survivor spaces will be one fourth of the heap.

    Anyway I don’t know why you need this requirement. I usually worry only about the throughput and only care for those parameters when the throughput is bad.

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

Sidebar

Related Questions

I would like to better understand the basic steps needed to a take an
I would like to write a vulnerable program, to better understand Stack Overflow (causes)
I would like to find a better algorithm to solve the following problem: There
I would like to know if is better to use application/javascript or application/ecmascript and
I would like to use this script https://github.com/jeromeetienne/jquery-qrcode (or is there even a better
I wish to better understand the real-world application of this new feature that consists
I'd like to better understand the reasons for .NET's application server model compared to
I would like to use the WebClient (or there is another better option?) but
I have a decent working web application (Java/Servlet/Jsp) that I would like to improve
I would like a hint or much better a solution for this: I do

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.