Reputation: 1
I am using Spring, Hibernate, Java 1.6 etc. I am having a complex logic that has multiple Arralists and Maps created within a method. The data is loaded from database into Lists and then manipulated to get data ready for jsp pages. If the same action is performed quickly and multiple times from that page, it hits the action frequently. As the huge data is processed in action with lists and maps, the applications throws Java Heap OutOfMemory.
If I apply -Xms -Xmx, then it will help to some extent, if my data grows this option will loose to memory issue. I would like to know, is there any way to clear the list once we manipulate and pass them to Model for jsp pages.
Upvotes: 0
Views: 196
Reputation: 510
Try using distributed memory caching solutions like - ehcache, Memcached, oracle coherence.
Upvotes: 0
Reputation: 4423
You can't recover from OOM as you never know when and where it will hit you.
Try to use lazy collections like in google's guava to manipulate on data without creating an extra copy. Use cursors and iterators to avoid full data stored in the memory.
Upvotes: 1
Reputation: 57421
Try to use SoftReferences for some big resources you need in memory.
Organize caching to free not necessary content from memory. See for example ehCache
Upvotes: 0