java.lang.OutOfMemoryError: bitmap size exceeds VM budget – Android

One of the most common errors that I found developing Android Apps is the “java.lang.OutOfMemoryError: Bitmap Size Exceeds VM Budget” error. I found this error frequently on activities using lots of bitmaps after changing orientation: the Activity is destroyed, created again and the layouts are “inflated” from the XML consuming the VM memory available for … Read more

performSelector may cause a leak because its selector is unknown

Solution The compiler is warning about this for a reason. It’s very rare that this warning should simply be ignored, and it’s easy to work around. Here’s how: if (!_controller) { return; } SEL selector = NSSelectorFromString(@”someMethod”); IMP imp = [_controller methodForSelector:selector]; void (*func)(id, SEL) = (void *)imp; func(_controller, selector); Or more tersely (though hard … Read more

C++ Memory Leak Using char *

You have your char *cstr = new char[data.size() + 1]; and the corresponding delete[] cstr; and these are implemented correctly (matching new[] with delete[]). Nowhere else in your code do you allocate memory on the heap, and I don’t see anywhere that cstr is modified either. All of these suggest that you don’t have a … Read more