Android :: Track Memory Consumption (Bitmaps)?

Mar 26, 2009

How can one track memory consumption in Android? The Android "Heap" view in Eclipse and java.lang.Runtime methods seem failing for my purpose. I tried to figure out how much memory my app consumes in order to make decisions for future directions. Most of the memory goes into Bitmap objects. Just to test memory consumption I created huge bitmaps in a Loop and logged the java.lang.Runtime memory values: created bitmap (610k free, 2371k total, 16384k max) created bitmap (615k free, 2371k total, 16384k max) created bitmap (615k free, 2371k total, 16384k max) created bitmap (615k free, 2371k total, 16384k max)

Nothing seems to hapen, but on the fifth Bitmap: java.lang.OutOfMemoryError: bitmap size exceeds VM budget at android.graphics.Bitmap.nativeCreate(Native Method) at android.graphics.Bitmap.createBitmap(Bitmap.java:343) at de.greenrobot.colorball.GameView.init(GameView.java:86)

This seems confusing at first. Is java.lang.Runtime the right place to check application memory stats in Android at all? Are Bitmaps allocated outside the app's heap? How can I track it?

Android :: track memory consumption (Bitmaps)?


Android :: Allocating Bitmaps And Out Of Memory Error

Jun 16, 2010

I'm running into OutOfMemoryErrors when allocating bitmaps. This is not something I can reproduce with emulators, and has been reported by a few beta testers with the HTC Incredible. I'm not sure I can solve this directly, and my best hope is to follow best practices for bitmaps and memory thereof. But looking for those best practices based on groups archives left me with more questions than answers. If anyone has a chapter about this in their book, I will buy the book. Here are the things I've mulled over so far:

1. I have a bitmap for a drawing buffer. It is about 3-4 megabytes on some devices. This is the biggest bitmap I have, and without it, I wouldn't be able to much of anything useful in my app. I am assuming that it would not be useful to use inPurgeable if this is a bitmap that is drawn into. Is this true?

2. Next biggest in the hierarchy are some bitmaps that are about 22K bytes and 256K unpacked. Since I believe about 25 of these might be used at one time, I have a cache with a size of 25. I am careful to use BitmapFactory.Options.InPurgeable, so I believe that could make them take only 22K each, but I don't see that as guaranteed. Maybe they are taking 256K each, which would put me in the danger zone. As they are cycled out of the cache, I call bitmap.recycle(). I think this a good practice. Is it?

3. Next are some resources with icon size 32x32 pixels. There are about 50 that could be used or reused. If I use code like this:

Drawable s = mCtx.getResources().getDrawable(R.drawable.symbol_icon);
Where s is a local variable to rendering. Suppose I call this 37 times. Am I to assume that Android will do something smart like create only one bitmap for this resource even if it is used 37 times? Or am I to assume that Android will do something stupid like create 37 bitmaps and keep references in an obscure location that will prevent garbage collection? Do I need to get more access to these bitmaps and do something smart myself?

4. Finally are some other icons used for menus and ImageButtons. Most are declared in layout files - so I don't touch the bitmaps directly.

I'd like to make my memory usage more efficient, but don't want to spend time on things that will amount to shuffling chairs on the Titanic. And how do I best measure this usage? Interestingly enough, I've tried using the Allocation Tracker and it says I haven't allocated a single bitmap. In light of the above, I don't think that's right.

View 11 Replies View Related

Android :: Bitmaps And Out Of Memory Error (Allocating Back Buffer)

Sep 2, 2010

We are also having occasional problems with OutOfMemory errors in createBitmap. It tends to happen after a few orientation changes when we are allocating the backbuffers. I have made it so that it calls recycle() on the old bitmaps (if any exist) and does a System.gc() before allocating the new backbuffers. What we are doing is allocating a backbuffer that is twice the width and height of the screen so that we can quickly zoom in and out.

With a 854x480 screen this would presumably be 6.25MB in size. The problem as I see it is the 16 or 24MB maximum heap size per process. This is unreasonably small, especially on devices that have 512MB of RAM. Ideally the max heap size should be something like 64MB, or perhaps allow apps to request a larger heap size from the user.

View 14 Replies View Related

Android :: Out Of Memory Error On Large Bitmaps And Activity Life Cycle

Jul 24, 2010

I have a scrollable map app which for now has a huge bitmap. It loads fine on startup, but when it looses foreground status and the user brings it backs again im getting an out of memory error. In onPause it trashes the bitmap using recycle, and marks it as null. The onResume checks to see if map==null and will load the bitmap back again, which is crashing the program despite me recycling the bitmap...Here are some bits of code. All of the other references to Bitmap map first check if it is null before loading/drawing..............

View 1 Replies View Related

Android :: Check Memory Consumption Of Each Running Processes Individually With SDK?

Apr 7, 2010

I would like to check the memory consumption of each running processes individually, cat /proc//statmis ok, but opening a shell for each check is time consuming, and maybe not the best way. any advices how to do it with the SDK?

View 1 Replies View Related

General :: Internal Memory Consumption - Hidden Files

Feb 21, 2012

I have only 150mb of internal memory on my phone. These are some items that consume critical amounts of internal memory space. When I download an app, it seems I am downloading an install package. The installed app itself takes up additional space. I believe the install package persists on the internal memory, invisible to the average retail user, and takes up internal space even after the app is moved to the card.

Ex: an anonymous app
android market listed size- 3.51mb (this must be the download size of the installer)
download and install on internal memory, size listed- 5.73mb
move to SD card, size listed- 2mb
move back to internal memory, size listed- 5.73mb

Further thoughts:

1. The install package seems to remain on the internal memory even though the app moves to the card.

2. Beyond the above example, I went through each and every item listed in my settings - applications - storage use - All.

I found 105 total items on internal memory and SD card all together. By adding up the listed "Total" size of each (yes, I went through each and every one), I arrived at approximately 109mb. The phone lists internal memory use at 135mb. I would expect the internal memory use to be LESS than 109mb because some of the apps are on the card. My assumption is that much of this extra internal storage is taken up by all of the installers sitting invisible on the internal memory.

3. Based on observing the change in the Internal Memory usage when I delete app "Data", I believe the app data is being written to the internal memory even if the app is on the SD card.

Why isn't the install package deleted after the app is successfully installed? Is there an app for that?If I uninstall the app while it sits on internal memory, does it also delete the install package?If I uninstall the app without first moving it back to the internal memory, does it delete the uninstall package? How can I reclaim this internal memory space for actual use??

View 2 Replies View Related

General :: Google Maps 6.10.0 And Extra Memory Consumption?

Aug 19, 2012

I own a (quite old now) Google Nexus One and I recently upgraded from Google Maps v6.9.0 to Google Maps v6.10.0

And I was quite surprised to see my user memory decrease a lot while the install apk is quite the same between both versions.

My Nexus One is rooted and running stock Android 2.3.6 (GB, not ICS)So I investigated and here is what I found about this new version of Google Maps.First, you must know that the memory available to the user to install new applications is mounted by the android system as '/data'.By running a 'du' command, I discovered that the following folder:

Code:
/data/data/com.google.android.apps.maps/app_
takes 11.9 Mo, which is a lot.[code].....

View 2 Replies View Related

Android :: Track Memory Used By OpenGL Textures?

Jun 19, 2010

How do I track the memory used by OpenGL textures in Android? I understand the texture memory is on the Video RAM, but do they get swapped in with the RAM? If I call glGenTextures and do not call glDeleteTextures, how does it impact the memory usage of my current process?

View 1 Replies View Related

Motorola Droid X :: GPS Functions Track / Keep History In Memory?

Jul 18, 2010

Does the stock Google maps app have waypoints you can set. Does it track and keep history in memory? If not, what is the best app to use with the GPS?

View 1 Replies View Related

Android :: ATrackDog - SD - Track Backup App Vs. ATrackDog - Track New Version

Dec 1, 2009

I was just wondering what the difference between aTrackDog(SD) and the regular aTrackDog? Which is better and more stable?

View 2 Replies View Related

Android :: Widget With Custom Bitmaps

Oct 1, 2010

I am writing a clock widget that uses customised bitmaps (so the widget loads the bitmap from the sdcard) Just have a couple of questions regarding how updates work:

1. if i want to display seconds on the clock widget will the widget load the bitmaps off the disk every second or can they be cached somehow so it doesn't reload off the disk each time. or If it does reload a bitmap each second, would this use a lot of power?

2. If i load the customised number bitmaps into a static array and then pass them as bitmaps to the widget would this use less power than just loading off the SD card?

View 6 Replies View Related

Android :: Unable To See Bitmaps At 0 0 Of Canvas

Jul 6, 2010

I have following example code:

Character c = CharacterFactory.getCharacter(CharacterEnum.SpecialCharacter); //factory has applicationContext reference to get bitmaps from R. ... Paint bitmapPaint = new Paint(); ... View::onDraw(Canvas canvas) ... canvas.drawBitmap(c.bitmap(), 0, 0, bitmapPaint);

For some reason (must be something simple) I do not see the bitmaps at the 0,0 of the canvas. Inspecting the bitmap and etc does not show anything obvious (nulls), I must have missed something. Is there something I should be paying particular attention to while drawing bitmaps?

View 5 Replies View Related

Android :: Compare Bitmaps In Canvas

Aug 18, 2010

I am using the above code for displaying bitmap.and i also move that bitmap.Now my qusetion is how i am compare bitmap with another bitmap. Please give me some suggestions.

View 2 Replies View Related

Android :: Load Bitmaps Into ImageViews

Oct 15, 2010

I want to load bitmaps into ImageViews in Android, but I don't want to use the R.drawable syntax because I have a lot of images with a standard naming convention so it's much easier to get the image with some logic. For example, all my images are named:

img1.png
img2.png
img3.png

So if a user selects a value, let's say x, I show "img" + x + ".png" in the ImageView. Looks like Bitmap.decodeFile is what I need, but I need to know the syntax of how to get to my drawables folder since that's where the images are. Or if there's perhaps a better way.

I realize I could do this with a switch statement instead of concatenating the image name but that would be a lot of lines since I have so many images.

View 3 Replies View Related

Android : Get Bitmaps Blurred Using Droid?

Sep 9, 2010

I am struggling to get Bitmaps blurred using Android.

I have seen a lot of information about using a simple kernel like

0 0 0 5 0 0 0
0 5 18 32 18 5 0
0 18 64 100 64 18 0
5 32 100 100 100 32 5
0 18 64 100 64 18 0
0 5 18 32 18 5 0
0 0 0 5 0 0 0


My problem is that I am really not sure how to multiply this with my Bitmap in an efficient way. Should I go through every pixel and image.getPixel(x, y)

while storing those values to a new array (so I don't have to get those values over and over again) and then go through the array and for each value add up the surrounding values multiplied by the corresponding field in the kernel divided by 1068 (in the case of the above kernel (= all entries summed up))?

Is there any better way to do this? Is there a simple solution for the borders?

Or is there even something available in the Android SDK I missed?

View 2 Replies View Related

Android :: Downloading Images And Converting To Bitmaps

Jun 16, 2010

I am working on an application that downloads images from a url. The problem is that only some images are being correctly downloaded and others are not. First off, here is the problem code:

public Bitmap downloadImage(String url) {
HttpClient client = new DefaultHttpClient();
HttpResponse response = null;
try {.......................................

So what I have is a method that takes the url as a string argument and then downloads the image, converts the HttpResponse stream to a bitmap by means of the BitmapFactory.decodeStream method, and returns it. The problem is that when I am on a slow network connection (almost always 3G rather than Wi-Fi) some images are converted to null--not all of them, only some of them. Using a Wi-Fi connection works perfectly; all the images are downloaded and converted properly. Does anyone know why this is happening? Or better, how can I fix this? How would I even go about testing to determine the problem?

View 2 Replies View Related

Android :: OutOfMemory With 9M Free Heap Because Of Bitmaps!

Mar 3, 2010

Our app has some memory peaks, which let the heap grow to 13M. After the peak, there's 9M of free heap. Everything's fine until Bitmap objects come into play. Despite having 9M of free heap creating Bitmaps, which have only some 100k, now fail with a OutOfMemoryException!

My theory: Allocation fails if (Java) heap *size* plus external allocations (e.g. Bitmaps) exceed 16M, no matter that there is lots of free memory in the heap. The VM could shrink the heap, but actually does not. Would be quite a flaw in the VM.

Does anyone share this theory?

On the downside of this theory: I do not see anything appropriate (killing the process is probably not) an app developer could do to prevent those OutOfMemoryExceptions given that those memory peaks are legitimate and unavoidable.

View 18 Replies View Related

Android :: GLSurfaceView Swaps 2D Bitmaps Being Drawn / Cause Of This Can Be?

Sep 8, 2010

I have an application that receives information from a database, and is used to visualize 2D bitmaps onto a GLSurfaceView. The information received will determine the x-position of the bitmap, and which bitmap image to use (there are 4 different bitmaps in my res folder to choose from).

Below are the three classes that are being used. The Activity sets the Shapes objects that need to be drawn by passing an ArrayList to the GLLayer class. This ArrayList is passed to the instance of ShapeStorage class via another setList method. This class is responsible for drawing when they are received.

The problem that I'm having is the following. Suppose I receive one object (let's say that it's a square at it's located at x=1). Some time goes by, and I receive another shape (this time, it's a triangle, and it's located at x=-1). However, when this new shape appears on the screen, the old bitmap's appearance changes to a triangle, and the new one becomes a square. In other words, the objects themselves are at the correct position that they are supposed to be at, but the bitmap being associated with them has changed. Does anyone know what the possible cause of this can be? I'm still a newbie to OpenGL-ES, and while this code looks very convoluted, it just involves setting a bunch of various properties for the View. code...

View 1 Replies View Related

Android :: App Gets Too Slow While Drawing Two Bitmaps On A Canvas / Fix It?

Nov 4, 2010

I have two bitmap overlapped .The top bitmap is transparent and when user touch to screen i copy pixels from another bitmap to top bitmap.My goal is to give to users the feeling of erasing image with touching to see another image.However it is not working properly especially when user drags his finger too fast on the screen.I made a few tests and i beleive drawing bitmaps to the canvas every time cause the lag but i don't know how to fix it.

View 1 Replies View Related

Android : Leaking Bitmaps From Adapter's GetView

Mar 31, 2009

I definitely have a memory leak problem and i'm trying to figure out there. After 6-10 config changes i'm getting out of memory in regards to BitmapFactory. I'm kind of suspect that this is going on within adapter. I have a listview . ListItems are an thumbnail image ( ImageView ) and TextView for text.

Here is the getView code.

CODE:..................

And get ThumbnailBitmap() is basically BitmapFactory.decodeByteArray ..

Is it possible that i'm leaking drawables ? Heap is not increasing by the way .

View 3 Replies View Related

Android :: Java.lang.OutOfMemoryError When Load Bitmaps

Jun 8, 2010

I used this sort of code to make sure my bitmaps load:................

In 2.2, it's now failing sometimes and my catch block no longer catches anything. Why would that be? Is there a better way to avoid a java.lang.OutOfMemoryError?

View 10 Replies View Related

Android :: Drawn Bitmaps Are Not Scrolling In Custom View

Nov 9, 2010

I am creating a CustomView with bigger image based on tutorial on and developers forum. It is scolling fine.I need exact pixel coordinates of my image.I am getting that also.now I want to draw some images upon scrolling image.I am able to draw images using onDraw().But images are not getting scrolled.Any idea how to resolve this?

View 4 Replies View Related

Android :: Bitmaps Loaded From Gallery Are Rotated In ImageView

Sep 5, 2010

When I load an image frome the media gallery into a Bitmap, everything works fine, except that pictures that were shot with the camera while holding the phone vertically, are rotated so that I always get a horizontal picture even though it appears vertical in the gallery. how can I load it correctly?

View 3 Replies View Related

Android :: Drawing Bitmaps On Screen In Game Without Slow Performance

Sep 16, 2009

I want to make a tile based game for android. At the moment I am drawing each tile as a separate bitmap. I have a big for loop that reads from a string and draws different tiles depending on what character it finds to draw the level. I have allowed the user to scroll the screen using scrolling gestures. However the game is too slow. It takes a long time to update the screen after the user scrolls. I presume this is because it has to draw each tile's bitmap individually. What would be a faster way to draw the level? I was thinking I could merge all the tiles into one bitmap. But I don't know how to do this.

Anyway here is my code so you can see the problem:
package org.example.tutorial2d;
import android.app.Activity;
import android.os.Bundle;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.GestureDetector.OnGestureListener;
import org.example.tutorial2d.Panel;
public class Tutorial2D extends Activity implements OnGestureListener {
GestureDetector gestureScanner; Panel main;
/** Called when the activity is first created. */
@Override public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
gestureScanner = new GestureDetector(this);
//requestWindowFeature(Window.FEATURE_NO_TITLE);
main = new Panel(this); setContentView(main); }
@Override public boolean onTouchEvent(MotionEvent me) {
return gestureScanner.onTouchEvent(me); }
@Override public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
main.handleScroll(distanceX,distanceY); return true; }
@Override public boolean onDown(MotionEvent e) { return true;
} @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { return true;
} @Override public void onLongPress(MotionEvent e){
} @Override public void onShowPress(MotionEvent e) {
} @Override public boolean onSingleTapUp(MotionEvent e) { return true; } }

And the class that does all the work:
package org.example.tutorial2d;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.util.Log;
import android.view.View;
import org.example.tutorial2d.Point;
public class Panel extends View {
private int scrollX = 0; private int scrollY = 0;
public Panel(Context context) { super(context);
} @Override public void onDraw(Canvas canvas) {
/*Bitmap scratch; //Drawable scratch;
//scratch = getContext().getResources().getDrawable(
// R.drawable.icon); canvas.drawColor(Color.BLACK);
//scratch.draw(canvas); int origin = 0;
scratch = BitmapFactory.decodeResource(getResources(), R.drawable.horizontal5);
canvas.drawBitmap(scratch, origin, origin, null);
int width = scratch.getWidth(); int height = scratch.getHeight();
scratch = BitmapFactory.decodeResource(getResources(), R.drawable.room4entrynesw3x3);
canvas.drawBitmap(scratch, origin + width, origin - 32, null);
[Code]

View 3 Replies View Related

Android :: Concate / Combine Two Bitmaps And Make Them One Image In Droid?

Sep 17, 2010

Can anyone tell me how to combine or concatenate two bitmap images into one in android?

View 2 Replies View Related

Android :: Draw Translucent Bitmaps Using Canvas Without Having To Resort To OpenGL?

Mar 17, 2010

I have a Bitmap object and want to render it to a Canvas object with varying levels of translucency (i.e. make the whole bitmap partially see through). For example, I have sprites in a game (that are drawn over the top of a bitmap background) that I want to fade out from being opaque to being invisible. Can I do this without having to resort to OpenGL?

View 2 Replies View Related

Android :: Method To Draw Bitmaps Faster On Droid Canvas / OpenGL?

Jun 15, 2010

I currently have a game written using the Android canvas. It is completely 2D, and I draw bitmaps as sprites on the canvas, and it technically works, but I have a few features that I need to add that will require drawing many more bitmaps on the screen, and there will be a lot more movement.

The app needs more power.

What is the best way to go from this method of drawing Bitmaps on a canvas to using OpenGL so I can draw them faster?

View 2 Replies View Related

Overlay Bitmaps With Click Of Button

Oct 27, 2011

I am currently working on an app and I want to lay a Bitmap over the Google Maps bitmap with the click of a button. I am assuming this is possible, and maybe a lot easier than I'm making it.

class MapOverlay extends com.google.android.maps.Overlay
{
@Override
public boolean draw(Canvas canvas, MapView mapView,
boolean shadow, long when)

[Code] ......

View 1 Replies View Related

Android :: Battery Consumption Analysis

Jun 11, 2010

My question is basically "can anyone recommend an application that will tell me which applications are draining my battery". I've read about task killers and usage and turning stuff on and off, I'm not worried about that, and I don't need to know why (i.e Google Earth uses X units per hour.

View 11 Replies View Related

Android :: How To Reduce Power Consumption

Jul 27, 2010

There are quite some pit falls that an application developer may hit. In order to simplify life Sony Ericsson Developer world has produced a little guideline called "Android Application Coding Guidelines - Power Save".

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved