Any way to avoid garbage collection on these lines? Bitmap.createBitmap / new Canvas(bitmap)

by Mark Murphy » Tue, 14 Apr 2009 22:12:18 GMT

Sponsored Links
 > I'm happy to keep a static or member reference to the Bitmap object

To me, the key word there is "many".

If really do mean "many", then cache the Bitmap (or perhaps the Canvas) in
a data member or local variable or something until you are outside your
loop and no longer need it. If at that point you are not expecting to
re-enter that loop for some time, null out the data member and let garbage
collection reclaim the space. If you are likely to re-enter the loop soon
and will need the exact same Bitmap again, you may as well hold onto it.

Mark Murphy (a Commons Guy) 
_The Busy Coder's Guide to Android Development_ Version 2.0 Available!


Other Threads

1. Error when try to make the kernel

Hi All,

I am trying to build a ROM which can run on HTC phones. I downloaded
the kernel code (android-msm-2.6.35) and built it using:

$ make ARCH=arm CROSS_COMPILE=../prebuilt/linux-x86/toolchain/arm-
eabi-4.4.0/bin/arm-eabi- msm_defconfig
$ make ARCH=arm CROSS_COMPILE=../prebuilt/linux-x86/toolchain/arm-

but I got this error:
arch/arm/mach-msm/pm.c: In function 'msm_pm_init':
arch/arm/mach-msm/pm.c:773: warning: assignment from incompatible
pointer type
arch/arm/mach-msm/pm.c:779: error: 'RESET_VECTOR' undeclared (first
use in this function)
arch/arm/mach-msm/pm.c:779: error: (Each undeclared identifier is
reported only once
arch/arm/mach-msm/pm.c:779: error: for each function it appears in.)
make[1]: *** [arch/arm/mach-msm/pm.o] Error 1
make: *** [arch/arm/mach-msm] Error 2

How can I solve this problem?




2. Native code segfault on Tegra2

First, you should try android-porting, not android-ndk

Do you know what the code that crashes does exactly? You should have a stack
trace that tells you where the problem is located, which might give you some
What compiler flags are you using when building with the gcc-4.4.0
toolchain. Not using the correct one is going to produce invalid machine
code (that's why there is an NDK in the first place).
Also, keep in mind that Tegra2 doesn't support NEON or VFPv3-D32 (but you
would get a SIGILL fault instead, so it's probably unrelated).


3. NullPointerException when creating an activity.

4. IMSI is null when airplane mode is not on.

5. /sys/class/gpio not registered

6. Location of display code in android 2.6.36 kernel.

7. Google Updates buat SPICA Froyo 2.2 (CM)