How to deal with java.lang.OutOfMemoryError

First, when java.lang.OutOfMemoryError  error thrown?

- when there is insufficient space to allocate an object in the Java heap
- when there is insufficient native memory to support the loading of a Java class
- when an excessive amount of time is being spent doing garbage collection and little memory is being freed


Check, Was it thrown 

- because the Java heap is full?
- because the native heap is full? 


Particularly, investigate right after the full GC happen.

- Mainly, it's about allocation and reference.
- Using profiler to check allocation and reference are on its purpose.
- soft reference / weak reference


Look into Code.

- Estimate the size of memory needed in the application.
- Evaluate how much you can reduce the amount of memory.
- get the leak point.


Rarely 

- increase max heap size
- scale-up/out  machine

References

https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/memleaks002.html
- https://stackoverflow.com/questions/299659/whats-the-difference-between-softreference-and-weakreference-in-java

Comments

Popular posts from this blog

삼성전자 무선사업부 퇴사 후기

개발자 커리어로 해외 취업, 독일 이직 프로세스

코드리뷰에 대하여