jvm

JVM 主动类和被动类的使用

与世无争的帅哥 提交于 2020-01-24 23:15:05
主动使用和被动使用Demo 1、创建工程一个Gradle工程 下一步 下一步 点击完成 2、创建类 public class MyTest1 { public static void main(String[] args) { System.out.println(MyChild1.str); } } class MyParent1{ public static String str = "hello world"; static { System.out.println("MyParent1 static block"); } } class MyChild1 extends MyParent1{ static { System.out.println("MyChild static block"); } }   输出结果: MyParent1 static block hello world   会发现MyChild1的类静态块没有执行。   总结:对于静态字段来说,只有直接定义了该字段的类才会被初始化。 修改后的类: public class MyTest1 { public static void main(String[] args) { System.out.println(MyChild1.str2); } } class MyParent1{ public

Heap Memory default allocation in Cassandra

孤人 提交于 2020-01-24 20:10:35
问题 As per cassandra-env.sh the default heap memory allocation for a 440G Total RAM should be 32765M (Maximum CAP before JVM Swithches to 64 bit reference). So, why is it showing 32210157568 bytes(30718M) when I query "java -XX:+PrintCommandLineFlags -version" or "java -XX:+PrintFlagsFinal -version | grep -iE 'MaxHeapSize'" Why is there difference, of around 2G. FYI: jvm.options files was default & using DSE 5.1.3. 回答1: java -XX:+PrintFlagsFinal has nothing to do with Cassandra, and I don't know

JPype won't compile properly

坚强是说给别人听的谎言 提交于 2020-01-24 14:19:05
问题 So I am having trouble compiling a very simple python script using JPype. My code goes like: from jpype import * startJVM(getDefaultJVMPath(), "-ea") java.lang.System.out.println("hello world") shutdownJVM() and when I run it I receive an error saying: Traceback (most recent call last): File "test.py", line 2, in <module> startJVM(getDefaultJVMPath(), "-ea") File "/usr/lib/pymodules/python2.7/jpype/_core.py", line 44, in startJVM _jpype.startup(jvm, tuple(args), True) RuntimeError: Unable to

JVM堆(heap)

我的未来我决定 提交于 2020-01-24 14:12:23
概念: 一个JVM实例只存在一个堆内存,堆内存的大小是可以调节的。类加载器读取了类文件后,需要把类、方法、常变量放到堆内存中,保存所有引用类型的真实信息,以方便执行器执行,堆内存分为三部分: 一个JVM实例只存在一个堆内存,堆内存的大小是可以调节的。类加载器读取了类文件后,需要把类、方法、常变量放到堆内存中,保存所有引用类型的真实信息,以方便执行器执行。 java7堆内存逻辑上分为三部分: 新生+养老+永久 java8堆内存逻辑上分为三部分: 新生+养老+元空间 (java7之前的图) 新生区 新生区是类的诞生、成长、消亡的区域,一个类在这里产生,应用,最后被垃圾回收器收集,结束生命。新生区又分为两部分: 伊甸区(Eden space)和幸存者区(Survivor pace) ,所有的类都是在伊甸区被new出来的。幸存区有两个: 0区(Survivor 0 space)和1区(Survivor 1 space)。当伊甸园的空间用完时,程序又需要创建对象,JVM的垃圾回收器将对伊甸园区进行垃圾回收(Minor GC),将伊甸园区中的不再被其他对象所引用的对象进行销毁。然后将伊甸园中的剩余对象移动到幸存 0区。若幸存 0区也满了,再对该区进行垃圾回收,然后移动到 1 区。那如果1 区也满了呢?再移动到养老区。若养老区也满了,那么这个时候将产生MajorGC(FullGC)

is the jvm faster under load?

无人久伴 提交于 2020-01-24 13:17:05
问题 Lots of personal experience, anecdotal evidence, and some rudimentary analysis suggests that a Java server (running, typically, Oracle's 1.6 JVM) has faster response times when it's under a decent amount of load (only up to a point, obviously). I don't think this is purely hotspot, since response times slow down a bit again when the traffic dies down. In a number of cases we can demonstrate this by averaging response times from server logs ... in some cases it's as high as 20% faster, on

Does javac also inline?

試著忘記壹切 提交于 2020-01-24 13:12:12
问题 I was playing around with javap and some very simple code and that raised a - hopefully simple - question. here is the code first: public class Main { public static void main(String[] args) throws Exception { System.out.println(m1()); System.out.println(m2()); } private static String m1() { return new String("foobar"); } private static String m2() { String str = "foobar"; return new String(str); } } Now I compiled the code and looked at the output (omitting -verbose for now). $ javap -c Main

HotSwapAgent plugin - plugin class not found

若如初见. 提交于 2020-01-24 11:20:28
问题 I have been developing custom plugin for HotSwapAgent, but encountered weird issue with classloader missing plugin class. This is the exception thrown by ####<Feb 9, 2015 12:45:54 AM PST> <Notice> <Stdout> <testbox.mycompany> <AdminServer> <Thread-87> <<WLS Kernel>> <> <> <1423471554463> <BEA-000000> <HOTSWAP AGENT: 0:45:54.463 ERROR (org.hotswap.agent.config.PluginRegistry) - Error in plugin initial processing for plugin package 'mycompany.infrastructure.hotswap.agent' java.lang

HotSwapAgent plugin - plugin class not found

五迷三道 提交于 2020-01-24 11:19:46
问题 I have been developing custom plugin for HotSwapAgent, but encountered weird issue with classloader missing plugin class. This is the exception thrown by ####<Feb 9, 2015 12:45:54 AM PST> <Notice> <Stdout> <testbox.mycompany> <AdminServer> <Thread-87> <<WLS Kernel>> <> <> <1423471554463> <BEA-000000> <HOTSWAP AGENT: 0:45:54.463 ERROR (org.hotswap.agent.config.PluginRegistry) - Error in plugin initial processing for plugin package 'mycompany.infrastructure.hotswap.agent' java.lang

jvisualvm定位JVM内存溢出,死锁,分析GC日志

倖福魔咒の 提交于 2020-01-24 06:47:34
OOM定位 创造一个会OutOfMemoryError的程序 import java . util . LinkedList ; import java . util . List ; public class OutOfMemoryDump { /** * JVM 参数 * -Xms10m -Xmx10m -XX:+PrintGCDetails -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/Volumes/mac */ public static void main ( String [ ] args ) { List < Byte [ ] > bytes = new LinkedList < > ( ) ; while ( true ) { Byte [ ] byteNew = new Byte [ 1024 ] ; bytes . add ( byteNew ) ; } } } 运行时添加虚拟机运行参数: - Xms10m - Xmx10m - XX : + PrintGCDetails - XX : + HeapDumpOnOutOfMemoryError - XX : HeapDumpPath = / Volumes / mac / oomdump . dump 然后可以在/Volumes/mac

Could increase gc time short lived object that has references to old lived object?

好久不见. 提交于 2020-01-24 04:20:17
问题 I need some clarification about how minor gc collections behave. calling a() or calling b() in a long-lived application, if they could behave worstly when old space gets bigger //an example instance lives all application life cycle 24x7 public class Example { private Object longLived = new Object(); public void a(){ var shortLived = new ShortLivedObject(longLived); // longLived now is attribute shortLived.doSomething(); } public void b(){ new ShortLivedObject().doSomething(new Object()); //