Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Linux \ Bitmap memory footprint of computing Android memory optimization     - SQL Server memory Misunderstanding (Database)

- Linux System Getting Started Learning: The Linux logrotate (Linux)

- Git / Github use notes (Linux)

- The virtual memory (Linux)

- Nginx Beginner Guide (Server)

- C data types is how it is supported by most computer systems (Programming)

- To install and configure the Jetty server and JDK under Ubuntu 14.04.2 (Server)

- APF firewall installation and configuration under Linux (Linux)

- IO reference Docker container (Server)

- RHEL7 Apache MPM configuration (Server)

- Mistakenly deleted redo log file group being given the lead to start the database ORA-03113 (Database)

- Ubuntu apt-mirror established local private sources (Linux)

- Linux Security (Linux)

- Why do you need close contact Rust 1.0 (Programming)

- Linux file content inspection - cat, tac, no, more, less, head, tail, od (Linux)

- C ++ you can become a new scripting language (Programming)

- Ubuntu 12.04 installed OpenCV 2.3.1, binary image (Linux)

- Using the Android interface in Parcelable (Programming)

- Java, on the dfile.encoding Systemproperty (Programming)

- echo command (Linux)

  Bitmap memory footprint of computing Android memory optimization
  Add Date : 2018-11-21      

Originally I was doing TV applications, but because the company wants a cell phone, staff nervous, so I transferred me to support it, I was told Lei Feng it! I made a phone function is to deal with the application of ICON, treatment is nothing more than beautify and re-synthesis and cutting the base plate, and uses a lot of knowledge of the Bitmap. Originally before always wanted to write something about Bitmap blog, this is just a chance so Bitmap knowledge blog series was born. Bitmap this series I will learn some knowledge of release for your reference and exchange.

Picture in your phone generally refers Bitmap images Bitmap why say it? Because everyone in the development of applications that they will use some pictures to show UI, users also like to look at pictures, see the text for information is too slow and not intuitive, if a good graphic design, basically do not watch to see pictures of your text on know what you want to express, for example, all shopping sites will edit many commodities with plans to be presented to the user, you can see in the picture application of common and important. As long as it comes to picture how to avoid OOM can not leave this topic, because when dealing with lots of pictures is prone OOM, then the learning image processing is particularly important, step by step, let us learn the relevant knowledge of the picture.

Bitmap image memory for computing:

Bitmap image loaded into memory when it is in accordance with: * width * height pixel bits to be calculated. You can put pictures as the line width, the column height of the matrix, each matrix element represents a pixel, each pixel is 1byte integer multiple of the data, the data, the more rich color representation, display the picture quality is higher. Bitmap has an enumeration class Config to configure the image compression format, each pixel is much data to store representatives, the greater the value the more color information can be stored, the more abundant, display it the better. Config.ALPHA_8 is 1 byte, Config.RGB_565 and Config.ARGB_4444 are 2 bytes, Config.RGB_565 no Alpha value to specify no transparency so multiple images, Config.ARGB_8888 is 4 bytes, are in accordance with the general picture of this to configure . The following is to get the configuration code:

static int getBytesPerPixel (Config config) {
    if (config == Config.ARGB_8888) {
        return 4;
    } Else if (config == Config.RGB_565) {
        return 2;
    } Else if (config == Config.ARGB_4444) {
        return 2;
    } Else if (config == Config.ALPHA_8) {
        return 1;
    return 1;

You need to pay attention to what use the picture:

1, Android system own problems.

android system assigned to each application a certain memory space allocated depends on the number of manufacturers and models, numerical Runtime class can get, Runtime.getRuntime () Gets an instance, then () method to obtain the system can be assigned by APP maxMemory the maximum memory, totalMemory () Gets the currently allocated APP memory heap space, freeMemory () Gets the current available memory, when it is depleted will automatically expand, but not more than maxMemory. The figure below shows the minimum memory google official website provides different resolutions in different dpi allocated;

2, require much photos.

In fact, when a lot of pictures displayed on the phone need not be completely loaded into memory in the picture, such as my cell phone camera to take a picture is 4208 * 3120, loaded into memory in the memory is 52M, which is very scary two photos almost put your app to run out of memory. Under normal circumstances you need to load image processing, this process is mainly to reduce the image size, lower resolution, such as your controls display size is 100 * 100, and then you take pictures reduced to 100 * 100 .

3, the timely release of memory.

Before Android 2.3.3 (API level 10), Bitmap Bitmap pixel data and objects are stored separately, the pixel data is stored in native memory, the object is stored in the Dalvik heap, and native memory pixel data is not in a predictable the way to release, could cause the application to temporarily exceed the limit of its memory and crash, so Android2.3.3 (API 10) before you have to call recycle () method to freed memory to avoid OOM, of course, the premise is no longer sure that the bitmap use, otherwise there will be. "Canvas: trying to use a recycled bitmap" after Android3.0 (API 11), Bitmap Bitmap object pixel data and stored together in Dalvik heap, so we do not have to manually call recycle () to release Bitmap object to release the memory of all the garbage collector to do.

These are some of the basics of learning and Bitmap loaded into the phone memory matters that need attention, the next article I will write how to better load Bitmap, how to save memory, how efficient.
- Git 2.5 increase in the working tree, triangle improved workflow performance (Linux)
- Tsung first test installation (Linux)
- Installation of Python2.7.8 and iPython under CentOS6.5 (Linux)
- sa weak passwords intrusion prevention (Linux)
- xargs Detailed description (Linux)
- Linux and SELinux Exploration Program Manager (Linux)
- ORA-00600: internal error code, arguments: [keltnfy-ldmInit], [46], [1], [], [], [], [], [] (Database)
- Atlassian Linux Shell Scripting the confluence remote backup methods (Linux)
- C ++ 11 feature: auto keyword (Programming)
- Installation Strongswan: on a Linux IPsec-based VPN tool (Linux)
- Nonstandard IMP-00010 error processing one case (Database)
- Java garbage collection (Programming)
- Installation and Configuration ISC DHCP server on Debian Linux (Server)
- Introduction and use of the Raspberry Pi (Linux)
- Shell programming entry (Programming)
- To access an Oracle database using Instant Client (Database)
- Let VMware ESXi virtual switch support VLAN (Linux)
- Ubuntu Gnome and Fedora 22 Gnome desktop, extended to achieve global menu (Linux)
- Linux System Getting Started Learning: the Linux Wireshark interface dead solve (Linux)
- Configuring the PXE server in Ubuntu 14.04 (Server)
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.