java.lang.OutOfMemoryError is the most common error that is encountered by java programmers. As the Exception suggests that the issue here is related to memory. Mostly it may not be a programmer's fault, but sometimes memory leaks in the code can cause this issue. The JVM (Java Virtual Machine) throws this error message when no more objects can be added to the heap due to memory not available or the garbage collector is not able to free up memory space.
Types of java.lang.OutOfMemoryError Error messagesThe OutOfMemoryError exception can occur due to various reasons, so let's look into a list of 7 different types of error messages one may encounter.
You are an Android Developer or a J2EE developer you will surely encounter one of the OutOfMemoryError errors listed below.
- java.lang.OutOfMemoryError: Java heap space
- java.lang.OutOfMemoryError: PermGen space
- java.lang.OutOfMemoryError: GC overhead limit exceeded
- java.lang.OutOfMemoryError: unable to create new native thread
- java.lang.OutOfMemoryError: Requested array size exceeds VM limit
- java.lang.OutOfMemoryError: requested bytes for Chunk::new. Out of swap space
- java.lang.OutOfMemoryError: (Native method)
- Java XML-RPC 3.1.x based web service example
- List of jars required for Struts2 project
- list of jars required for hibernate 4.x.x
- How to create StackOverflow error in java
- Tutorial Java SOAP WebServices JAS-WS with Eclipse J2EE IDE and Tomcat Server Part 1
- import servlet API to eclipse project (javax.servlet cannot be resolved error)
- [Solved] com.sun.xml.ws.transport.http.servlet.WSServletContextListener ClassNotFoundException
- Convert String to int in Java
- JSP Hello World Program Tutorial with Eclipse and Tomcat Server
- SharePoint Open in the client application document opens in browser
- Java: TimeZone List with GMT/UTC Offset
- Struts2 : java.lang.ClassNotFoundException: org.apache.commons.fileupload.RequestContext
- Remove Trailing zeros BigDecimal Java
- [Solution] Java Error Code 1603. Java Update did not complete.
- Maven Eclipse (M2e) No archetypes currently available
- error: file not found: HelloWorld.java
- Exception in thread main java.lang.NoClassDefFoundError: package javaClass
- 7 deadly java.lang.OutOfMemoryError in Java Programming
- How to check if Java main thread is alive
- [Hibernate] The method buildSessionFactory() from the type Configuration is deprecated
- Java XML-RPC java.net.BindException: Address already in use
- Eclipse : The type java.lang.CharSequence cannot be resolved. Indirectly referenced from required .class files
- Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end users experience
- Eclipse : A java Runtime Environment (JRE) or Java Development kit (JDK) must be available
- List of jar files for Jax-ws (SOAP) based Java Web Services
- [Java Threads] Should we extend Thread Class or implement Runnable interface
- Maven Unsupported major.minor version 51.0
- hibernate.cfg.xml Configuration and Mapping xml Example
- How to verify if java is installed on the computer and get version detail
- Unhandled exception type InterruptedException : Java Threads
- XmlRpcException ConnectException connection refused error
- Error: Unable to access jarfile jarFileName.jar file [Windows]
- BeanDefinitionStoreException IOException parsing XML document from class path resource [spring.xml]
- How to serialize-deserialize an object in java
- List of Java Keywords
- Simple Struts 2 Tutorial in eclipse with tomcat 7 server
- Struts 2 Hello World Example in Eclipse
- Your JBoss Application Server 7 is running However you have not yet added any users to be able to access the admin console
- List of Java versions
- Create simple struts2 project using maven commands
- Struts 2 : There is no Action mapped for namespace [/] and action name [form] associated with context path [/proj]
- Error: Can not find the tag library descriptor for
- connection.url property value in hibernate.cfg.xml for mysql
- Unbound classpath container: JRE System Library [JavaSE-1.7]
- Setting Java_Home Environment variable on Windows Operating System
- Calculate Volume of Pyramid - C-Program
- Launch Notepad++ html document in any web browser - NotepadPlusPlus
- Sublime Text spell check shortcut - Sublime
- Download interrupted: Unknown Host dl-ssl.google.com Error Android SDK Manager - Android
- Android Launch! The connection to adb is down, and a severe error has occured - Android
- How to resolve Certificate Expired WhatsApp Error - WhatsApp
- Transfer files between Android and Mac OS X using usb cable - Mac-OS-X
- Make Bootstrap Button look like a link - Bootstrap
- Horizontally Center Align tag in HTML using CSS - CSS
- Android R Cannot Be Resolved To A Variable - Android
- Convert SQL to CSV in Notepad++ - NotepadPlusPlus
- Hide Scrollbar from Android Views - Android
- Error running 'app': No target device found. - Android-Studio
- PHP 301 Redirect Permanently - PHP
- How to enable Do Not Disturb mode for Notification Center in Mac OS X 10.10 Yosemite - Mac-OS-X
This is the most common type of OutOfMemoryError error, its thrown when the JVM heap size if full and the GC garbage collector is unable to reclaim any objects. As discussed earlier it can be a genuine memory issue, or an issue caused due to memory leak. There are various tools available that can help you analyze code memory leaks. Reading heap dumps using analyses tools can help resolve memory leaks (example YourKit and JProfiler)
PermGen space is a part of JVM. It is the space that is reserved for the long-term object. Garbage collection in PremGen happens only when under certain circumstances. This kind of error is thrown when PermGen space memory is full.
This error message is thrown when the Garbage Collector it taking too long to recover too little memory. You would see a sharp increase in the CPU time utilization to free up a very little amount of memory.
This OutOfMemoryError error is thrown when the java process size has reached its maximum limit. This error is encountered mostly when too many threads are spawned.
This OutOfMemoryError exception is thrown when you exceed the maximum size a Java Array object can have (usually Integer.MAX_VALUE of 2GB)
This OutOfMemoryError exception is thrown when the JVM memory is full. It usually happens when there are too many processes running on the machine.
The native code of Java is usually written in C (or maybe C++ too). As the exception tell the problem here is with the native code.
Error Stacktracejava.lang.OutOfMemoryError: Java heap space
at java.nio.HeapIntBuffer.(Unknown Source)
at java.nio.IntBuffer.allocate(Unknown Source)
at com.sun.javafx.tk.quantum.UploadingPainter.run(Unknown Source)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.runAndReset(Unknown Source)
at com.sun.javafx.tk.RenderJob.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)java.lang.OutOfMemoryError: Java heap space
at java.nio.HeapIntBuffer.(Unknown Source)
at java.nio.IntBuffer.allocate(Unknown Source)
at com.sun.javafx.tk.quantum.UploadingPainter.run(Unknown Source)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.runAndReset(Unknown Source)
at com.sun.javafx.tk.RenderJob.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
java.lang.OutOfMemoryError: Java heap space
at java.nio.HeapIntBuffer.(Unknown Source)
at java.nio.IntBuffer.allocate(Unknown Source)
at com.sun.javafx.tk.quantum.UploadingPainter.run(Unknown Source)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.runAndReset(Unknown Source)
at com.sun.javafx.tk.RenderJob.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(Unknown Source)