Showing posts with label Java Virtual Machine. Show all posts
Showing posts with label Java Virtual Machine. Show all posts

java.lang.OutOfMemoryError: Java heap space Error in JVM

 Heap size is larger than your computer's physical memory. For example,

java -Xmx2g BigAppError occurred during initialization of VMCould not reserve enough space for object heapCould not create the Java virtual machine.
The fix is to make it lower than the physical memory: java -Xmx1g BigApp


Incorrectly use mb as the unit, where m or M should be used instead.

java -Xms256mb -Xmx256mb BigAppInvalid initial heap size: -Xms256mbCould not create the Java virtual machine.
The heap size is larger than JVM thinks you would ever need. For example,

java -Xmx256g BigAppInvalid maximum heap size: -Xmx256gThe specified size exceeds the maximum representable size.Could not create the Java virtual machine.
The fix is to lower it to a reasonable value: java -Xmx256m BigApp

The value is not expressed in whole number. For example,

java -Xmx0.9g BigAppInvalid maximum heap size: -Xmx0.9gCould not create the Java virtual machine.
The correct command should be java -Xmx928m BigApp

What is a Java Virtual Machine (JVM)?

To understand the Java virtual machine you must first be aware that you may be talking about any of three different things when you say "Java virtual machine." You may be speaking of:
  • the abstract specification,
  • a concrete implementation, or
  • a runtime instance.
The abstract specification is a concept, described in detail in the book: The Java Virtual Machine Specification, by Tim Lindholm and Frank Yellin. Concrete implementations, which exist on many platforms and come from many vendors, are either all software or a combination of hardware and software. A runtime instance hosts a single running Java application. Each Java application runs inside a runtime instance of some concrete implementation of the abstract specification of the Java virtual machine. In this book, the term "Java virtual machine" is used in all three of these senses. Where the intended sense is not clear from the context, one of the terms "specification," "implementation," or "instance" is added to the term "Java virtual machine".

How to Increase JVM / Java Heap Size,Increasing JVM / Java Heap Size Tutorial

Java programs executes in JVM uses Heap of memory to manage the data. If your Java program requires a large amount of memory, it is possible that the virtual machine will begin to throw OutOfMemoryError instances when attempting to instantiate an object. The default heap size if 1 MB and can increase as much as 16 MB.

It is possible to increase heap size allocated by the Java Virtual Machine (JVM) by using command line options.
Following are few options available to change Heap Size.

-Xms<size>        set initial Java heap size
-Xmx<size>        set maximum Java heap size
-Xss<size>        set java thread stack size
 
Also we can set the Minimum and Maximum Heap size
 
java -Xms64m -Xmx256m MyProgram

jvm out of memory error,Java Out of Memory

I have a question I'm hoping to get some help with.  I have an Oracle 8.1.7 database running on a unix server. The server is also running a java virtual machine. I don't know much about the jvm, but i do know one is running. i have to have it running to run a pl/sql process that uses the oracle xdk package. when i try to run my process with too many reports to parse, i get the error:

ORA-29554: unhandled Java out of memory condition

i assume this means that the jvm ran out of available ram. my question is, does anyone know the details of how to up the memory avaialable to the jvm on the server? if anybody has another opinion on what exactly is causing this error and how to fix it that would be great too. thanks.


Solution:
take a look at that and try setting the two parameters in the init.ora file:

Oracle introduced the following two new init.ora parameters to limit Java  session memory usage:

JAVA_SOFT_SESSIONSPACE_LIMIT  - This parameter allows you to specify a soft limit on the amount of Java         memory usage in a session. If this parameter is exceeded, a message is written to the alert.log. The default is 1 MB.  
JAVA_MAX_SESSIONSPACE_SIZE   - This parameter sets a hard limit on the amount of Java memory usage a  session can have. If a session exceeds this parameter, it terminates  with the following error: ORA-29554 : unhandled Java out of memory condition
The default is 4 GB.  This limit was purposely set very high so that it would not normally be visible.

JVM crash on a Red Hat machine ( Java 1.4.2 applicationwith ) with a SIGSEGV error. -Xms is 64M and -Xmx is 128M

I'm running a Java 1.4.2 application on a Red Hat machine that causes the JVM to crash with a SIGSEGV error. -Xms is 64M and -Xmx is 128M. I first thought that the perm gen size was too low since it always has a high percentage (98/99%) when the JVM crashes. After reading more about the perm gen, though, I'm not so sure. Am I looking down the right path by thinking it may be the perm gen size being too low or is the percentage so high just because the JVM will resize it dynamically? When it crashes the perm gen's total size is around 10/11 MB and its usually 99% full.

#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
#  SIGSEGV (0xb) at pc=0xb7c70b4c, pid=5342, tid=2810452880
#
# Java VM: Java HotSpot(TM) Client VM (1.4.2_16-b05 mixed mode)
# Problematic frame:
# V  [libjvm.so+0x196b4c]
#


Heap
 def new generation   total 4608K, used 3372K [0xa7900000, 0xa7e00000, 0xa82d0000)
  eden space 4096K,  78% used [0xa7900000, 0xa7c27780, 0xa7d00000)
  from space 512K,  27% used [0xa7d80000, 0xa7da3ad8, 0xa7e00000)
  to   space 512K,   0% used [0xa7d00000, 0xa7d00000, 0xa7d80000)
 tenured generation   total 60544K, used 21376K [0xa82d0000, 0xabdf0000, 0xaf900000)
   the space 60544K,  35% used [0xa82d0000, 0xa97b0210, 0xa97b0400, 0xabdf0000)
 compacting perm gen  total 11264K, used 11159K [0xaf900000, 0xb0400000, 0xb3900000)
   the space 11264K,  99% used [0xaf900000, 0xb03e5c30, 0xb03e5e00, 0xb0400000)
  
  
   ---------------  S Y S T E M  ---------------

OS:Red Hat Enterprise Linux Client release 5 (Tikanga)

uname:Linux 2.6.18-8.1.8.el5 #1 SMP Mon Jun 25 17:06:19 EDT 2007 i686
libc:glibc 2.5 NPTL 2.5
rlimit: STACK 10240k, CORE 0k, NPROC 16370, NOFILE 1024, AS infinity
load average:0.00 503...

CPU:total 2 family 15, cmov, cx8, fxsr, mmx, sse, sse2

Memory: 4k page, physical 1034572k(314260k free), swap 2096472k(2096472k free)

vm_info: Java HotSpot(TM) Client VM (1.4.2_16-b05) for linux-x86, built on Sep 17 2007 00:34:43 by unknown with unknown compiler
 

Functionality of JVM(Java Virtual Machine)

Java sovles the problem of platform independence by usingbyte code.Java complier does not produce native executablecode.
Instead it produces a special format called byte code.Byte code is a highly optimized set of instructionsdesigned to executed by a java runtime system called JavaVirtual Machine(JVM).JVM is an interpreter for byte code.
This interpreter reads or understands the bytecode andexecutes the corresponding native machine instructions.Thus to port java programs to a new platform ,all thatneeded is to port the interperter and some of the libraryroutines.
Even the complier is written in java.The bytecodes are precisely defined and remain the same on allplatforms.The use of byte code  enables the java runtime system toexecute programs much faster.
The JVM is the core of the Java platform and is responsible for:

1. Loading bytecodes from the class files
2. Verifying the loaded byte codes
3. Linking the program with the necessary libraries
4. Memory Management by Garbage Collection
5. Managing calls between the program and the host environment.