Posts

Showing posts with the label JVM

Testing JVM resources availability in docker environment

Introduction JVM is changing over the time what makes us, Software Engineers, to periodically measure stability of our applications. JVM flag adaptations can be needed not only when upgrading JDK but also when we are changing available app cloud resources. If we pay for resources, we should use them in the most effective way. This article provides useful scripts and code to make resource control easier. All scripts and code used in this article you can find in this GitHub demo Testing JVM flags To test default JVM flags values depending on given resources I’m using script docker-jvm-flags.sh (available on github repo). You can easily modify it according to your preferences. Basically it runs JRE docker image with given memory and CPUs resources and for each of them executes command to get default JVM flags and filtering (with grep) those, which we specified on JVM_FLAGS_TO_PRINT list. docker-jvm-flags.sh JVM_IMAGE_NAME="e...

Remote JVM debug

Image
This article describes how to debug a Java application which is running on remote server. We have two things to do: enable and specify debug port on JVM which is running our app, connect to that JVM. In this example let's expose port 8083 for debuging by adding this flag for our JVM: -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8083 command for running our app should look like that: java -jar -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8083 app-name.jar Now let's connect to that JVM. I will use IntelliJ IDE for that. First step is to create new configuration of "Remote JVM Debug" type: Next, the remote address and port have to be specified. I'm running my application on localhost and exposed debug port is 8083:   After that just run new configuration:   Debug console should show information that remote debugger was connected to app: When debugging a remote app a good practice is to avoid "stop the world" for o...