jvm

How to avoid memory leaks in java programs

Although jvm has a garbage collection mechanism, if the program is written without paying attention to some specific rules, it can still lead to memory leaks in java programs, which may end up with OutOfMemory exceptions. 1. Causes of memory leaks in Java Objects in java are divided into 2 types in terms of usage, referenced and unreferenced. Garbage collection only recovers objects that are not referenced. Referenced objects, even if they are no longer used, are not recycled.

Java Class File Format Analysis

Preface Learn jvm word code, you need to understand the way class is composed, this article explains the process of parsing the class file format in java method, I hope it can help you. Class file specification The code that is compiled and executed by the Java virtual machine uses a platform-neutral (hardware- and operating system-independent). It is often (but not always) stored as a file, so this format is called the Class file format.

Application of Volatile

Memory Visibility Since the Java Memory Model (JMM) states that all variables are stored in main memory, and each thread has its own working memory (cache). When a thread is working, it needs to copy the data from the main memory to the working memory. This way, any operation on the data is based on the working memory (which is more efficient) and cannot directly manipulate the data in the main memory or the working memory of other threads, and then flush the updated data to the main memory afterwards.

Java Startup Params

Basic Format Run java -help to see the basic format and options [root@localhost ~]# java -help Usage: java [-options] class [args...] (execute class) or java [-options] -jar jarfile [args...] (execute jar file) Startup options are omitted [-options]: options [-options]: options [args...] : Passes a parameter to the main method Standard options -help / -? : output help information -version : output version information -classpath / -cp: class search path for directories and zip/jar files .