Principles and memory allocation of Java virtual machines for Android Development

Source: Internet
Author: User
Principles and memory allocation of Java Virtual Machine for Android development Author: Android Development Network original time:

To develop efficient and stable Android applications, we have to understand the principles of Java virtual machines and the memory allocation mechanism. Android uses Google's optimized Dalvik Java VM. Generally, the Code Compiled by Java is a class file that is analyzed and validated by the class parser of Java Vm and then executed. The essential difference between Java and C/C ++ is memory management. Java VM has a garbage collection cleaner GC that can automatically recycle memory.

When executing the code, the Java Virtual Machine first parses the class and looks for the methods and constants of the class. In general, the Code compiled into binary is stored in the jar file, for Java reflection, Vm class loaders need to dynamically search for these class names. Although compilation time is saved, searching during runtime greatly reduces the running efficiency.

For Android applications, mobile phone Ram is much smaller than PC, and mainstream applications on the computer use visual c ++ for programming, therefore, for hardware that is not dominant on mobile phones, a large memory language such as Java must have a strict understanding of memory release to improve program performance. For the memory release of Android, you can see it in the logcat in ddms, similar to 08:10:18. 895: Debug/dalvikvm (1281): GC freed 38611 objects/2097960 bytes in 182 Ms. You can get a rough idea about the collection of objects in your application,

Generally, Android applications use about 20 mb of Ram. For programmers, we try to use code rendering instead of textures. Next let's take a look at the memory usage tracking: First, we find the devices device management in the ddms of Eclipse, select the process to be viewed, and click the green button of the update head above, switch to the heap page and click the cause GC button,

If you cannot find the process of your application on the left, you can run your software on your mobile phone first, and do not forget the update heap button above, only a few marked as red are allowed.

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.