Meaning of the "Unloading class" messages
Anyone can explain why the lines below appear in the output console at runtime ?
(one possible answer would be full permGen, but this can be ruled out since the program only uses 24MB out of the max100MB available in PermGen)
[Unloading class sun.reflect.GeneratedSerializationConstructorAccessor28]
[Unloading class sun.reflect.GeneratedSerializationConstructorAccessor14] [Unloading class sun.reflect.GeneratedSerializationConstructorAccessor4] [Unloading class sun.reflect.GeneratedMethodAccessor5] [Unloading class sun.reflect.GeneratedSerializationConstructorAccessor38] [Unloading class sun.reflect.GeneratedSerializationConstructorAccessor36] [Unloading class sun.reflect.GeneratedSerializationConstructorAccessor22] [Unloading class sun.reflect.GeneratedSerializationConstructorAccessor8] [Unloading class sun.reflect.GeneratedSerializationConstructorAccessor39] [Unloading class sun.reflect.GeneratedSerializationConstructorAccessor16] [Unloading class sun.reflect.GeneratedSerializationConstructorAccessor2] [Unloading class sun.reflect.GeneratedConstructorAccessor1]The program runs with the following params:
-Xmx160M
-XX:MaxPermSize=96M -XX:PermSize=96M -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+PrintGCTaskTimeStamps -XX:+PrintHeapAtGC -XX:+PrintTenuringDistribution -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -verbose:gc -Xlo开发者_如何学JAVAggc:/logs/gc.logThere's plenty of space in the heap and in permGen.
Those classes are hold as softreferences which are always eligible for GC. The GC does not per se only run when the max memory is reached, it will also run when there is room for it, if you understand what I mean.
Those classes are by the way used "under the hoods" of the Serialization API which uses reflection to access fields and invoke methods.
Update: as to logging the class unloading to stdout instead of the path as specified in -Xloggc
, there has been a bugreport for exactly this problem: Bug ID 6637203. This was fixed 4 months back. Upgrade your JVM to the latest.
精彩评论