Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I am trying to analyze the java application using VisualVM tool and am getting the following statistics.
.
What I don't understand is why my app is utilizing approx 100% of CPU, and what are the ways I can detect and resolve memory-related issues in java application.
The project is developed on Spring Boot and is deployed on Apache Tomcat Server.
Thanks.
Edit:
My project used to utilize a max of 30% of CPU but now it's utilizing 100% and because of it most of the APIs are taking a lot of time to respond.
You could use a Profiling tool like JProfiler or VisualVM to analyze what your application is doing at that time. You could also connect a debugger and just "pause" the threads, that's a hack that may give you some hint on where to look for what is actually happening.
From your screenshot I'm not really seeing any memory specific issues, but using a profiling tool will also allow you to analyze which classes have instances with allocated memory.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I am currently working on an event driven System with multiple components running. Recently , I have received an urgent requirement to identify the memory consumption of java components running , so that we can give a brief idea of memory requirements before it is getting deployed on UAT/customer production environments.
Do we have any API using which Deep retained size can be calculated or a formula can be provided using which memory requirements can be computed.
Any ideas on this will surely help.
I have seen some API's ( java instrumentation Api) using which Shallow size can be calculated , but this will not suffice my need.
I also found java Assist using which java byte code can be modified at runtime.
To identify the memory consumption of a java aplication, you can use a profiler.
In jdk 6 or greater you can find jvisualvm (https://docs.oracle.com/javase/8/docs/technotes/tools/unix/jvisualvm.html).
With jvisualvm, you can attach to a java process and, in sampler tab, you can see the memory consumed grouped by class type.
There are even other powerful profilers (JProfiler is one of them)
Enable garbage collection logging and analyze the log. As a bonus you will also be able to identify (and fix) aberrant behaviour.
To turn on gc logging, use the following flags:
-verbose:gc
-XX:+PrintGCDetails
-XX:+PrintGCDateStamps
-XX:+PrintTenuringDistribution
-XX:+PrintGCCause
-Xloggc:/gc-%t.log
This log file can then be handled in a number of tools like Censum from JClarity or uploaded to https://gceasy.io/ for easy analysis. Note that you will see the memory consumption as a whole for the app, not a breakdown. For that you will have to use something like VisualVM mentioned above.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
It just so happened, that I have created a class that has 1000+ lines.
After installing the app on the device, the application starts slowing the device really hard. Will rewriting this script to three different classes, approximately 300 lines each, solve my issue?
If your application uses the internet, it is possible, that the phone has a worse connection than your comp. Slower connection - you have to wait...
Read responsive App and App performance - VERY useful. you will know the name of your problem - bad responsiveness (not performance) - for better further searches
No. The problem is not about how many lines are there, or how many classes, it is about the complexity of the algorithms and time each action takes.
Try to use Threads or Handlers while possible to make the app more responsive.
Also, don't do too much work inside onCreate(), onResume() methods to make the app load faster.
Use Systrace. It is a great tool provided by Android community to help improve your app's performance by giving a detail info on what is happening in your app at a very low level.
It has many tutorials on how to use it available as official docs and on there YouTube Channel. But surely this software will do only good if you have some core concepts about the android operating system and how memory, threads etc are utilised. But you can also learn them along the way.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
I have tomcat 8 and running a web application on tomcat. Recently I noticed my Vsphere client showing alarms for high cpu usage and found that the process responsible for is tomcat. When I restart the tomcat server it is running good, but after some time, the same problem arise. How to solve this issue?
/data/IMS/java/bin/java -Djava.util.logging.config.file=/data/IMS/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048
This is a broad topic, so I can only really provide you with some pointers on how to debug remote applications.
If you want to get some visibility into what your App is doing you can use a tool like Visual VM. Visual VM can profile cpu and memory usage, see details here. In order to do profiling you need to:
Enable JMX on Tomcat. Docs on how to do this for Tomcat 8 are here.
Run Visual VM and point it at your Tomcat server's JMX connection. Tutorial here.
Do some cpu usage profiling and look at memory usage to get a better idea about what is happening. Formulate some hypotheses and test them out. Repeat the process until you stumble upon a solution.
If I had to guess what was going wrong, I would say memory usage is gradually increasing over time, and garbage collection starts taking a long time.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
So I am currently working on designing a game that will be multiplayer and to prepare for this I have begun looking at hosting options. Besides hosting from my house on a dedicated server, the best and cheapest option I found was the use of VPS, more specifically Dotblock. Now dotblock has both linux based and windows based VPS but the windows one is a lot more expensive and so my question is whether or not I will run into problems if I code my server program in java on my Windows computer but then eventually host it on a linux based VPS?
As far as I know there should be no problems but if there will be, what are they, and if there are no problems what limitations will I have while coding? I understand I cannot reference anything Windows specific but will things such as time and tracking the mouse using LWJGL should change?
Thank you in advance and I hope you guys can help me out!
Overall it's relatively straightforward- that's one of the advantages of using java over other languages. I will offer you this advice; make sure you handle file paths in an environment-agnostic way. I've seen more than one error log on linux complaining that it can't reach 'c:\some\weird\path'.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
how to use JNI in JSP page?.In net i found that
1. because if anything goes seriously wrong in the C part of your application, it will very likely crash your J2EE server, downing all other web services and applications it is running.
because the 'reactivatable' nature of web applications means there is no guarantee that a static initializer will not be executed more than once during one JVM run.
Unless you're confident of the reliability of your JNI-linked library, I'd strongly recommend not doing this, for the reasons you've identified.
I'd recommend decoupling the application server from your native code, and make the native library available via some remote mechanism (e.g. web service / REST / simple socket). That way you've isolated the app server from any fatal problems related to the native code.