Hibernate solution that does not release memory when processing large amounts of data

Source: Internet
Author: User
With the advancement of information, the system's dependence has become more and more strong, so a variety of data accumulation, data development rate is not high, so the data is not accurate and efficient use, this time we need to export data to Excel and then through the manual processing, but when the database data query out, found that the JVM memory continues to rise, know memory overflow, at first I thought the list is too large, I fixed the list to 1w, and then constantly loop to the database to fetch data, found that the problem is still there, there is no change, so the source of the problem, not the list, so continue to look for, Starting with the useless code isolation, found that the problem occurred in Hibernate, careful testing, found the memory of the continuous growth of the place is the Query.list () method, in order to improve efficiency, as much as possible to occupy memory, eventually lead to memory data leakage, so, I used the most direct method, List.clear () Set empty, found no effect, it makes me very incomprehensible, this return results directly return a reference, not the real list, at this time has been almost half a day past, the problem is still not solved, think of the previous data volume, many problems did not appear, So adjust the mentality, continue to look at the API, found that the session can solve the problem, so hurriedly try, sure enough, within a certain range of stability down, and data export time and efficiency significantly improved, excel2007 in 5 minutes to export 100W data to 1 sheet table is very easy, Problem solved, but still feel very uneasy, originally I know hibernate knowledge just a surface, a lot of usage is not very understanding, realization principle, realization way has not studied, so, to go the road is very long, want to learn to know a lot, re-pick up their passion, began to study hard

Hibernate solution that does not release memory when processing large amounts of data

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.