Deep parsing of Grow heap (Frag case) heap memory _android

Source: Internet
Author: User
Tags sqlite sqlite database

For Android developers, while using a Java language that automates memory management, it is possible that your application will continue to resemble Info/dalvikvm-heap (10798) in the case of memory mismanagement: Grow Heap (Frag case) to 6.437MB for 1114126-byte allocation, which appears
The value behind the Grow heap is increasing, and then the Android system begins to end the background task to add to the growing heap memory problem, which may eventually occur directly oom, and sometimes gc freed 0 objects/0 bytes in 75ms such a problem, for Java memory management We have recently said, on the above issues Android123 for you to do a simple analysis.

1. here Grow heap (Frag case) to the 6.437MB for 1114126-byte allocation indicates that you have been allocating a larger object that occupies up to 6.4MB of heap memory.

2. the question arises as to why a single object such as this is so large that the Android development network reminds us that this is a very dangerous operation because of the allocation of a byte[] array and the need to write the SQLite database in a BLOB format. Devices with different firmware and low RAM configurations are at any time oom dangerous, if you really need to go to the SQLite storage binary, here you can take a segmented way to split an object into 1MB or smaller, more fields to store, the middle plus a layer of split data cache layer to solve better.

3. each time a single large object is constructed, the GC can be notified of the preparation of the collection, such as the execution of System.GC () prior to the execution of the consuming operation; To prevent the occurrence of OutOfMemoryError, for Java memory overflow problem, we will use a variety of cases to explain.

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.