How to load tiles from a large bitmap in Android?

Answer from Romain Guy in Is it possible to chop a bitmap to small pieces without loading the entire thing into memory?: Android 2.3.3 has a new API called android.graphics.BitmapRegionDecoder that lets you do exactly what you want. You would for instance do the following: BitmapRegionDecoder decoder = BitmapRegionDecoder.newInstance(myStream, false); Bitmap region = decoder.decodeRegion(new Rect(10, … Read more

What happen to pointers when vectors need more memory and realocate memory?

Short answer: Everything will be fine. Don’t worry about this and get back to work. Medium answer: Adding elements to or removing them from a vector invalidates all iterators and references/pointers (possibly with the exception of removing from the back). Simple as that. Don’t refer to any old iterators and obtain new ones after such … Read more

Difference between local allocatable and automatic arrays

For the sake of clarity, I’ll briefly mention terminology. The two arrays are both local variables and arrays of rank 1. alloc_array is an allocatable array; automatic_array is an explicit-shape automatic object. Being local variables their scope is that of the procedure. Automatic arrays and unsaved allocatable arrays come to an end when execution of … Read more

Problem dealloc’ing memory used by UIImageViews with fairly large image in an UIScrollView

I’ve solved the mystery – and I’m pretty sure this is a bug on Apple’s side. As Kendall suggested (thanks!), the problem lies in how InterfaceBuilder loads images from the NIB file. When you initFromNib, all UIImageViews will init with a UIImage using the imageNamed: method of UIImage. This call uses caching for the image. … Read more

Performance: memset

As others already pointed out, Linux uses an optimistic memory allocation strategy. The difference between the first and the following memcpys is the initialization of DataDest. As you have already seen, when you eliminate memset(DataSrc, 0, N), the first memcpy is even slower, because the pages for the source must be allocated as well. When … Read more