Category : jvm

SoftReference is a soft reference, second only to strong reference, and is reclaimed when OOM is about to occur after garbage collector GC if there is not enough memory. WeakReference is a weak reference, second only to soft reference. When the JVM recycles garbage, objects associated with weak references will be recycled regardless of whether ..

Read more

Use G1 java -Dcom.sun.management.jmxremote -Djava.rmi.server.hostname=192.168.2.215 -Dcom.sun.management.jmxremote.port=1098 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=true -Dcom.sun.management.jmxremote.access.file=jmxremote.access -Dcom.sun.management.jmxremote.password.file=jmxremote.password -server -Xmx512m -Xms512m -XX:PermSize=128m -XX:MaxPermSize=256m -XX:+DisableExplicitGC -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:MaxGCPauseMillis=10 -XX:GCPauseIntervalMillis=200 -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/root/logs/dumps -Xloggc:/root/logs/gc/gc-$(date +%Y%m%d-%H%M%S).log -jar start.jar Use cms java -Dcom.sun.management.jmxremote -Djava.rmi.server.hostname=192.168.2.215 -Dcom.sun.management.jmxremote.port=1098 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=true -Dcom.sun.management.jmxremote.access.file=jmxremote.access -Dcom.sun.management.jmxremote.password.file=jmxremote.password -server -Xmx512m -Xms512m -XX:PermSize=128m -XX:MaxPermSize=256m -XX:+DisableExplicitGC -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+PrintGCDetails -XX:+PrintTenuringDistribution -XX:+PrintGCTimeStamps -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/root/logs/dumps -Xloggc:/root/logs/gc/gc-$(date +%Y%m%d-%H%M%S).log -jar start.jar ..

Read more

Before JDK6, constant pools were part of the permanent zone, but after JDK7, they were moved to the heap for management. The string. int () method obtains a symbol reference in the constant pool, and if the constant string does not exist in the constant pool, the method adds the string to the constant pool. ..

Read more

1. Modify bytecode The tools to be used in the first step are ASM, javassist and cglib (ASM-based), which are used to modify bytecode. 2. Load new bytecode The second step is to customize the ClassLoader to load the modified bytecode. 3. Replace the original bytecode Or replace the original bytecode, there are mainly two ..

Read more

String constant pool Literal quantity creation form, stringstr1 = “droid”; The JVM detects this literal quantity, and here we think that no object with droid content exists. If the JVM cannot find the existence of a string object with droid content through the st ring constant pool, it will create the string object, then place ..

Read more

Use fixed agent Introduction of pom <dependency> <groupId>net.bytebuddy</groupId> <artifactId>byte-buddy</artifactId> <version>1.4.16</version> </dependency> <dependency> <groupId>net.bytebuddy</groupId> <artifactId>byte-buddy-agent</artifactId> <version>1.4.16</version> </dependency> Example public static void installAgent(){ ByteBuddyAgent.install(); AgentBuilder agentBuilder = new AgentBuilder.Default() .type(nameStartsWith(“com.codecraft.demo”) .and(not(isInterface())) .and(not(isStatic())) .transform((builder,typeDescription,classLoader) -> builder .method(ElementMatchers.any()) .intercept(MethodDelegation.to(TraceInterceptor.class) ); agentBuilder.installOnByteBuddyAgent(); Use your own agent public static void premain(String argument, Instrumentation inst) { System.out.println(“start premain)”); new AgentBuilder.Default() .type(nameStartsWith(“com.codecraft.demo”).and(not(isInterface())).and(not(isStatic()))) .transform((builder,typeDescription,classLoader) ..

Read more

View java processes (jcmd) jcmd -l Or .. jps Or .. jinfo -flags pid View startup parameters (VM.flags) jcmd pid VM.flags Or .. jps -lvm View live objects (GC.class_histogram) jcmd <PID> GC.class_histogram jcmd <PID> GC.class_stats Or .. jmap -histo:live <PID> Or view the entire heap. jmap -heap pid Dump memory (GC.heap_dump) jcmd pid GC.heap_dump demo.hprof ..

Read more

Order Statsd-jvm-Profiler is a JVM agent Profiler developed by etsy, which sends profile data to statsd. -javagen load -javaagent:/usr/etsy/statsd-jvm-profiler/statsd-jvm-profiler.jar=server=statsdHost,port=statsdPort Runtime dynamic loading Copy the jar package to the main resource directory of the spring boot project, and then @Bean public CommandLineRunner loadProfilerAgent(){ return new CommandLineRunner() { @Override public void run(String… strings) throws Exception { ApplicationPid ..

Read more

Use jcmd to display flags specified directly on the command line. :%jcmd process_id VM.command_line JVM tuning flags that are effective for applications can be obtained in the following ways:%jcmd process_id VM.flags [-all] Flags show flags set by the command line and flags directly set by the JVM (because their values are determined by automatic optimization). ..

Read more

JIT compilers are available in 3 versions:32-bit client compiler (-client)32-bit server compiler (-server)64-bit server Compiler (-d64)To some extent, the compiler you choose to use depends on the command line option parameters given (-server, etc.). If it is a 32-bit operating system, then you must use a 32-bit JVM. If it is a 64-bit operating system, ..

Read more

Order This article focuses on the jvm’s PermGen and Metaspace Java memory structure Generation concept For garbage collection algorithms, generational recycling is one of the advanced algorithms. Objects are divided into generations according to the generation time. Young objects that have just been generated are classified as young gen-generation, while objects that have survived for ..

Read more