在Android的位图 [英] Bitmaps in Android

查看:121
本文介绍了在Android的位图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于位图对象和内存及通用分类标准的几个问题。

  1. 什么是内存或本机位图?
  2. 如何为位图从内存堆内存不同?
解决方案

这是备份一个位图对象,使用分配的内存本土code(的malloc()) ,而不是Java的关键字。这意味着,存储器直接管理由OS,而不是通过的Dalvik

本机堆和的Dalvik的堆之间真正的区别是,Dalvik的堆中被垃圾回收,和本机一个没有了。

为了这些目的虽然,这里是没有太大的区别。当你的位图对象被垃圾回收,它的析构函数会回收相关的内存,本机堆。

来源:

  • <一个href="http://osdir.com/ml/AndroidDevelopers/2009-03/msg00023.html">http://osdir.com/ml/AndroidDevelopers/2009-03/msg00023.html
  • <一个href="http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=graphics/java/android/graphics/Bitmap.java">android:platform/frameworks/base/graphics/java/android/graphics/Bitmap.java
  • <一个href="http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=core/jni/android/graphics/Bitmap.cpp">android:platform/frameworks/base/core/jni/android/graphics/Bitmap.cpp

I have a few questions regarding Bitmap objects and memory and their general taxonomy.

  1. What is an in-memory or native bitmap?
  2. How is Bitmap memory different from Heap memory?

解决方案

The memory that backs a Bitmap object is allocated using native code (malloc()), rather than the Java new keyword. This means that the memory is managed directly by the OS, rather than by Dalvik.

The only real difference between the native heap and Dalvik's heap is that Dalvik's heap is garbage collected, and the native one isn't.

For these purposes though, here's not much difference. When your Bitmap object gets garbage collected, it's destructor will recycle the associated memory in the native heap.

Source:

这篇关于在Android的位图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆