Explain the reason of Out of Memory exception in Java

Explain the reason of Out of Memory exception in Java.

- The OutOfMemoryException can occur either the JVM may have a limit of memory to access to, or the system may have run out of physical memory or the application might consume too much memory space.

- To avoid these situations to occur, the applications need to be rewritten or reconfigure the heap by increasing the size for JVM.

- Other causes for this exception are as follows:

1. Spikes in usage/data volume:

- An application may be developed to handle a few amount of users or data but suddenly the volume of data or the users may increase and that time this trigger may function java.lang.OutOfMemoryError: Java heap space error.

2. Memory leaks:

- More memory will be consumed due to some programming errors. The leaking functionality of the application used will leave some of the objects in the heap space.

- With time this space is consumed and will trigger java.lang.OutOfMemoryError: Java heap space error.
What will happen when ResultSet is not closed?
In a pooled database connection, it is returned to the pool and could close only after expiring its life time......
Explain the use of Clonable,and serializable interface.
The similarity of Clonable and Serializable interfaces is that they both are marker interfaces.....
How do we allocate an array dynamically in java?
Arrays in java are static lists that can store a certain kind of variables. Therefore these arrays need to be initialized at the compile time....
Post your comment