-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Areas to continue improving memory calculation #494
Comments
So, after doing more research it appears that "Total doesn't match linux process memory" is most likely a native memory leak for this application. That's good because that bunch of unaccounted for memory was scary. |
@glyn Want to take a look at this and come up with a concrete proposal for changes? |
@glyn @nebhale Here is an interesting idea. In the issue above I listed several native memory areas discovered using Native Memory Tracking that we currently aren't accounting for. Instead of attempting to devise methods to guess what we think these values should be in most situations, we should simply start a JVM with the same opts as the application and determine overhead based on the output of
Then add up the committed memory of all the areas we want to get a value for. From my testing it appears this provides a great initial value for System Threads size and GC size at the very least. Symbol and Internal not so much. I would propose that we use the entire application's opts untouched, with the exception of Xms which should be the same as Xmx, allowing any javaagents to also initialize and capture data from them as well. Granted, we may not have a final -Xmx value at this point but a decent candidate for this value should work just fine. Thoughts? |
A possible downside of this approach is it wouldn't work with java 7. |
With all the improvements of JBP 4 I'm still running into applications that grow outside their container.
I've been studying more about java native memory allocation and this issue contains some further areas that the JBP might consider accounting memory for.
I've been doing some tests with some of our applications with
-XX:NativeMemoryTracking=summary
turned on. (http://docs.oracle.com/javase/8/docs/technotes/guides/vm/nmt-8.html)Here is the output of one of my applications:
Reserving Thread space memory off of Xss doesn't account for system thread and their different stack size
Problem
This particular container is running 84 system and application threads. I'm using
-Xss256K
yet Java is using 41808KB of memory for stack allocation. 30 of my 84 threads are System threads which -Xss doesn't apply to. In addition many of those threads are GC threads which will vary based on the GC type used.Solution?
Allow for a configurable System Thread static base value that can be used to provide a best guess buffer considering GC type used and stack size of native threads. Then add onto that the configured thread value multiplied by
Xss
value. In the case of G1GC This value would probably be about 30MBGC Size Not accounted for at all
Problem
The application above is using the G1 GC which is using a wopping 106352KB of memory. To my knowledge this memory area isn't accounted for in JBP4 at all. Running some tests it appears that the GC area grows and shrinks with the Heap size specified.
Solution
The JBP should account for GC memory size by using a factor of total heap size allocated. This factor should be configurable because it will change based on the GC used. SerialGC uses much less memory. Some testing needs to take place to determine a proper factor for the default GC.
In this sample the Heap is set to
-Xmx2601674K
. So this application could benefit from a GC Memory factor of ~5%.Total doesn't match linux process memoryProblemJava Native memory calculator says java is using 1757634KB But linux says the process is using 2.036g.Solution?Worth additional study to understand how to account for this.Turns out this is probably a native memory leak in the application.
Misc items to investigate further
This report shows several other items of native memory not accounted for that might be worth investigating. Most notably
Internal
andSymbol
. More testing and analysis could be done here to help determine if the JBP can do anything smart with these.Summary
I think there is still some work that can be done to better account for Java memory in the JBP. The Native Memory Tracking tools is a great help in discovering this data.
The text was updated successfully, but these errors were encountered: