Although Android Developers use a Java language that can automatically manage memory, improper memory management may lead to frequent usage of apps like info/dalvikvm-heap (10798 ): grow heap (frag case) to 6.437 MB for 1114126-byte allocation
The value after grow heap is increasing. Next, the android system starts to end background tasks to increase the heap memory. In the end, oom may occur directly, at the same time, GC may also cause GC freed 0 objects/0 bytes in 75 Ms. We have recently mentioned the Java memory management, we will give you a simple analysis on these issues.
1. Grow heap (frag case) to 6.437 MB for 1114126-byte allocation indicates that you have been allocating a large object, and the heap memory occupied has reached 6.4 MB.
2. why is there such a problem? After inquiry, it indicates that a byte [] array is allocated, and a single object is large because it needs to be written to the SQLite database in blob mode, here, the android Development Network reminds everyone that this operation is very dangerous. For devices with different firmware and low Ram configurations, there is a danger of OOM at any time. If you really need to store binary data to SQLite, here, we can split an object into 1 MB or smaller segments and store them in more segments. It is better to add a layer of split data cache layer in the middle.
3. at the same time, before constructing a single large object, you can notify the GC to prepare for collection. For example, you can execute system before execution of the required operation. GC (); prevents outofmemoryerror. For Java memory overflow, we will explain it through various cases in the future.