What is the principle and usage of JVM Log technology
This article shows you the JVM Log technology principle and usage is what, the content is concise and easy to understand, absolutely can make you shine, through the detailed introduction of this article I hope you can gain something.
The implementation of each class of JVM Log not only naturally uses inheritance, but also effectively encapsulates the creation and release functions of JVM Log by using the C++ specific technique of overloading new/deleteoperator.
JVM Log Introduction
In debug versions of JVM, hotspot.JVM Log is output. Set GC's JVM Log with the parameter-XJVM Loggc:FileName.
JVM Log is implemented primarily in
\hotspot\src\share\vm\utilities\ostream.hpp \hotspot\src\share\vm\utilities\ostream.cpp \hotspot\src\share\vm\utilities\xmlstream.hpp \hotspot\src\share\vm\utilities\xmlstream.cpp \hotspot\src\share\vm\utilities\defaultStream.hpp
The main classes are: outputStream, fileStream, xmlTextStream, defaultStream
Inheritance relationships are:
ResourceObj
|
|-- outputStream
|
|--- fileStream
|
|--- xmlTextStream
|
|--- defaultStream
defaultStream::instance is the primary interface invoked by other modules.
Initialization of JVM Log
ostream_init() initializes defaultStream::instance
ostream_init_JVM Log() initializes JVM Debug Log and JVM Log for GC,
The core code is: defaultStream::instance->has_JVM Log_file(); it calls voiddefaultStream::init_JVM Log() instead; this is the code that really works.
defaultStream::init_JVM Log code is written very clearly, there is only one C++ syntax point to note: overloaded newoperator.
ostream.cppline346
fileStream*file=new(ResourceObj::C_HEAP)fileStream(try_name);
This is because the parent class of outputStream is ResourceObj, which overloads new and deleteoperator. Not much to say about C++ syntax, there are too many good books on the subject.
Final release of JVM Log
Threads::destroy_vm()
|
|--> exit_globals()
|
|--> ostream_exit()
|
|--> Release each JVM Log with delete operator
The implementation of each class of JVM Log not only naturally uses inheritance, but also effectively encapsulates the creation and release functions of JVM Log by using the C++ specific technique of overloading new/deleteoperator.
The above content is the JVM Log technology principle and usage is what, you have learned knowledge or skills? If you want to learn more skills or enrich your knowledge reserves, please pay attention to the industry information channel.