0

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.

trincot
356k37 gold badges278 silver badges337 bronze badges
asked Feb 13, 2013 at 6:19
3
  • 3
    OutOfMemory is Error, not Exception and cannot be recovered from. Commented Feb 13, 2013 at 6:25
  • why don't you try processing your data into chunks? Commented Feb 13, 2013 at 6:30
  • Welcome to the world of Big Data. Try solutions like, Hadoop, HBase or some other less complex batch procession solution like Spring batch. Commented Feb 13, 2013 at 7:12

3 Answers 3

1

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.

answered Feb 13, 2013 at 7:00

Comments

0

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

answered Feb 13, 2013 at 6:36

Comments

0

Try using distributed memory caching solutions like - ehcache, Memcached, oracle coherence.

answered Feb 13, 2013 at 7:03

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.