[AC-3034] Using lots of graphics drastically increases VM memory footprint on Android
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2012-01-10T08:32:26.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Titanium SDK & CLI |
Labels | android, crash, feature, ios |
Reporter | Sven Herzberg |
Assignee | Paul Dowsett |
Created | 2012-01-10T08:11:55.000+0000 |
Updated | 2016-03-08T07:48:04.000+0000 |
Description
As our application uses quite some images for its visual representation, we started to run into memory issues on Android once we introduced different layouts.
Relevant snippets from LogCat:
01-05 10:45:35.285: E/AndroidRuntime(460): FATAL EXCEPTION: main
01-05 10:45:35.285: E/AndroidRuntime(460): java.lang.OutOfMemoryError: bitmap size exceeds VM budget
01-05 10:45:35.285: E/AndroidRuntime(460): at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
01-05 10:45:35.285: E/AndroidRuntime(460): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:459)
A possible solution would be to manually load images and assign them to the views' backgrounds directly, like this:
var group;
var win;
var tab;
var view;
Titanium.UI.setBackgroundColor('#000');
group = Titanium.UI.createTabGroup();
win = Titanium.UI.createWindow({
backgroundColor:'#fff',
title: 'Test'
});
tab = Titanium.UI.createTab({
icon: 'KS_nav_views.png',
title: win.title,
window: win
});
var img = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory + '/KS_nav_ui.png').read().image;
view = Titanium.UI.createView({
backgroundImage: img
});
win.add(view);
group.addTab(tab);
group.open();
However, this doesn't work with Titanium's current implementation (no background on Android; Crash on iOS -- shouldn't this rather be an exception than a crash?). Due to TC-550, using Ti.UI.ImageView isn't an option either.
So, given that I want to improve the way the memory is managed and you simply provide a link to a document which doesn't solve my problem, should I go away from Titanium and instead develop app natively, so I can at least improve the way the memory is managed?
Also, see the overviews in [this section](https://wiki.appcelerator.org/display/guides/Cross-Platform+Mobile+Development+In+Titanium) of the "Building Mobile Applications with Titanium" book.
None of these overviews bring me closer to improving the memory footprint of the application.
A ticket needs to prove the existence of a bug, for it to be accepted. I'm afraid that this does not, in its current form. Please kindly refer to the [How to Submit a Bug Report](https://wiki.appcelerator.org/display/guides/How+to+Submit+a+Bug+Report) guide to learn how tickets need to be filed. Please also remember to raise a [Q&A question](http://developer.appcelerator.com/questions/created) (and to allow time for people to respond) before opening a ticket. Thank you