Currently, the Android platform has a good overall performance. Most of the calls are from Dalvik API to the underlying layer through JNI, but there is a big gap between the Game Performance and objective-C of the iPhone, the latest findings include the following improvements:
1. First, for memory, refer to the android heap memory. You can also customize the size and optimize the heap memory allocation of the Dalvik virtual machine.
2. In terms of basic types, Because Java does not have actual pointers, it is still necessary to use ndk for sensitive operations. Android123 prompts game developers. What is interesting is that Google launches ndk to help game developers. For example, the support of OpenGL ES has been significantly improved, and it is necessary to operate the graphical interface of local code.
3. image object optimization. Here we want to talk about the destruction of Bitmap objects on Android. You can use the recycle () method to display and let GC reclaim a bitmap object, the following method can be used for a non-bitmap, as shown in figure
If (bitmapobject. isrecycled () = false) // if not recycled
Bitmapobject. Recycle ();
4. currently, the system is relatively mentally retarded in animation support, which can be used for the transition between regular applications. However, for games, normal artists may be used to unified GIF Processing, currently, the android system can only preview the first frame of a GIF. You can read Resources in the gif89 format by using a thread and a self-writing parser in j2s.
5. For most Android phones without too many physical buttons, we may need to imagine a good gesture recognition gesturedetector and gravity sensing for control. We usually need to consider noise reduction for misoperation problems.
You can also customize the size of the android heap memory.
For some large Android projects or games, there is no problem in algorithm processing. The main cause of the performance bottleneck is the memory management mechanism of Android. Currently, mobile phone manufacturers are stingy with Ram, for the smoothness of software, Ram is very sensitive to the performance impact. Apart from the optimization of the heap memory allocation of the Dalvik Virtual Machine mentioned in the android Development Network last time, we can also forcibly define the memory size of our software. We use the Dalvik provided by Dalvik. system. the following example uses the vmruntime class to set the minimum heap memory:
Private Final Static int cwj_heap_size = 6*1024*1024;
Vmruntime. getruntime (). setminimumheapsize (cwj_heap_size); // set the minimum heap memory size to 6 MB. Of course, for memory compression, manual GC interference can also be performed. We will refer to the specific application next time.
Optimize heap memory allocation of Dalvik virtual machines
For the Android platform, the Dalvik Java VM used by its hosting layer can be optimized from the current performance, for example, when developing large game or resource-consuming applications, we may consider Manual Interference with GC and use Dalvik. system. the settargetheaputilization method provided by the vmruntime class can improve the processing efficiency of the program heap memory. Of course, we can refer to the open-source project for specific principles. Here we only talk about the usage: Private Final Static float target_heap_utilization = 0.75f; vmruntime can be called during oncreate. getruntime (). settargetheaputilization (target_heap_utilization.