Is the JVM launched if an unused class is absent?

Consider the program: public class Test { public static void main(String[] args) { if (Arrays.asList(args).contains("--withFoo")) { use(new Foo()); } } static void use(Foo foo) { // do something with foo } } Is Foo required in the runtime classp

Get information about using jvm memory in java code

There are many ways to analyze jvm memory usage offline, like MAT, jmap. However, is there any way to measure the memory usage inside the code during the runtime? Any advice will be much appreciated.Please refer to the official Java documentation, i.

When does the JIT inline the methods automatically?

I've heard that JIT automatically inlines small methods, like getters (they have about 5 bytes). What is the boundary? Is there any JVM flag?HotSpot JIT inlining policy is rather complicated. It involves many heuristics like caller method size, calle

Java process crashes, no thread dump can be taken

I am facing with a strange case. I'd be glad if you could share your comments. We have solution running on Java 1.6.085 and sometimes Java process is getting hang in production. The solution is running on Linux server. I investigated GC logs, there i

Too many open files in Java

i'm call this method several times: private static void writeFile(double val, String myFile) throws IOException { FileWriter file = new FileWriter(myFile, true); file.write(val + "\n"); file.close(); } After a periode i have this exception : Exc

Set Djava.library.path programmatically (or alternatives)?

I am looking to set the VM argument Djava.library.path programmatically. If this can't be done, what are the alternatives (if there are any)?take a look at this java doc http://docs.oracle.com/javase/6/docs/api/java/lang/System.html#setProperty(java.

Why is my JBoss JVM wrapper application restarted?

My OS version is Windows 7 64 bit and the JDK is 32 bit version. I started my JBoss Wrapper Application successfully, but after it ran for a while the JVM failed and restarted. The message in the JVM dump log is: # # There is insufficient memory for

OQL all instances of a package

Is it possible in OQL to retrieve all the objects that belongs to a package? Or can I query with wildcards? As @haridsv suggested I tried: SELECT * from "com.example.*" and SELECT a from "com\.example\..*" but in VisualVM it complaints

Threads and optimization of enumeration

I've got a method in an enumeration that is called by many threads running at same time. Because the JVM allows only one instance of an enumeration to be allocated in memory, I guess there are some optimisation being done somewhere either by the comp

options for G1 garbage collectors are not available?

http://www.oracle.com/technetwork/java/javase/tech/g1-intro-jsp-135488.html seems to be the official docs for the G1 garbage collector. There are two options mentioned: -XX:+G1ParallelRSetUpdatingEnabled -XX:+G1ParallelRSetScanningEnabled When config

How can I see what my Java process is doing now?

I have an app server process that's constantly at 100% CPU. By constantly I mean hours, or even days. I know how to generate a heap/thread dump, but I'm looking for more dynamic information. I would like to know what is using so much CPU in there. Th

System.gc () calls by the main APIs

Some of you probably know that some of core java APIs make explicit calls to System.gc(). I know two cases when this happens: NIO. I believe that is done to do some cleanup for direct ByteBuffers, when system runs out of "direct" memory. RMI. He

What is the purpose of compressed object pointers?

Following my question on whether the CLR could use compressed pointers, the answer was that it's pretty pointless. Still, some JVMs are implementing it, so what are the concrete benefits of this optimization, since gaining 4 bytes doesn't seem worth

Threads Tomcat! = JVM threads?

The Tomcat Manager reports a different thread count than ThreadMXBean. The number of threads reported by ThreadMXBean is the same as the number of threads reported in the YourKit profiler as well. Is there a difference between Tomcat threads and JVM

Determine the location of the JVM executable during execution

How does one obtain the location of the executable of the currently running JVM during runtime? I would like to instantiate another JVM as a subprocess using the ProcessBuilder class. I am aware that there is the java.home System property, but this d

Arbitrary JVM Behavior

Imagine a setup of 6-7 servers all identical with identical java version "1.6.0_18" OpenJDK Runtime Environment (IcedTea6 1.8) (fedora-36.b18.fc11-i386) OpenJDK Server VM (build 14.0-b16, mixed mode) each running a program (memory and CPU intens

Efficiency of Java code with primitive types

I want to ask which piece of code is more efficient in Java? Code 1: void f() { for(int i = 0 ; i < 99999;i++) { for(int j = 0 ; j < 99999;j++) { //Some operations } } } Code 2: void f() { int i,j; for(i = 0 ; i < 99999;i++) { for(j = 0 ; j <

How does Parrot compare to other virtual machines?

Parrot is the virtual machine originally designed for Perl 6. What technical capabilities does the Parrot VM offer that competing virtual machines such as the Java Virtual Machine (JVM)/Hotspot VM and Common Language Runtime (CLR) lack?The following

What is Java writing?

What language is Sun's JVM written in?Sun actually has multiple JVMs. The HotSpot JVM is written largely in C++, because HotSpot is heavily based on the Animorphic Smalltalk VM which is written in C++. More interesting than HotSpot is IMHO the Maxine