Reputation: 2638
This is the error I am receiving on the Android log, exactly, this is:
08-06 12:16:28.763: E/dalvikvm-heap(27065): Out of memory on a 184-byte allocation.
The "184" depends, sometimes it is 184, sometimes it is 24, other 42......etc....
I was looking everywhere, and this error is common for Activities where loading pictures, my problem is that I am not loading picture, but only text. My Activity is a ListActivity, where I load data from a DataBase(only text), and after a while, all the time the same error.
Anyone knows how to solve it??
Thanks a lot!
Upvotes: 1
Views: 5809
Reputation: 16988
In my case, the problem caused by big-size images. I removed some of them (temporarily for test) and the problem solved. Note that in my case, the problem just was in lowest API-level I was trying the app (API 16).
Finally, optimized them for solving the problem permanently.
Upvotes: 0
Reputation: 7958
Since you are using a listActivity check if you have implemented the optimizations shown here.
I solved a similar issue with list view by implementing the optimization
Here are some excerpts from the presentation about optimizing a listAdapter
The Slow way
public View getView(int position, View convertView, ViewGroup parent) {
View item = mInflater.inflate(R.layout.list_item_icon_text, null);
((TextView) item.findViewById(R.id.text)).setText(DATA[position]);
((ImageView) item.findViewById(R.id.icon)).setImageBitmap(
(position & 1) == 1 ? mIcon1 : mIcon2);
return item;
}
The Proper way
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = mInflater.inflate(R.layout.item, parent, false);
}
((TextView) convertView.findViewById(R.id.text)).setText(DATA[position]);
((ImageView) convertView.findViewById(R.id.icon)).setImageBitmap(
(position & 1) == 1 ? mIcon1 : mIcon2);
return convertView;
}
The Best Way
static class ViewHolder {
TextView text;
ImageView icon;
}
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.list_item_icon_text,
parent, false);
holder = new ViewHolder();
holder.text = (TextView) convertView.findViewById(R.id.text);
holder.icon = (ImageView) convertView.findViewById(R.id.icon);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.text.setText(DATA[position]);
holder.icon.setImageBitmap((position & 1) == 1 ? mIcon1 : mIcon2);
return convertView;
}
Upvotes: 3
Reputation: 4297
Sometimes you can get OutOfMemory error, when you try to execute too long SQL statements (eg, you don't use the String[]
argument for the variables in the query, but hard code them in the statement).
Try editing your where statements to field=?
format, and specify the variables in the designated query parameter.
See this thread: Sqlite Out of Memory when preparing update statement
If this isn't the problem in your case, than I can't think of anything else with this little information.
Upvotes: 0