Android :: Manage Severla Bitrmap For A ListView Avoiding OutOfMemory
Nov 17, 2010
I have to manage several Bitmap in a ListView where each row is composed by one thumbnail and one textview. This ListView can be very long, over 500 rows...
There are two problems I have to solve:
1) it is better if I cache all the bitmaps, maybe using SoftReferences in a HashMap. I've tried this way, but I noticed a strange behavior with the SoftReferences. It seems that the GC clean them too fast. Why?
2) In order to implement the cache correctly I'd also like to understand which is the best practice you suggest me to realize a "image lazy loading". For example... I'm thinking to load all the data for first and then to load only the thumbnails, but only those really visible on the device screen at the and of the scroll action.
View 4 Replies
Jan 25, 2010
I am facing an Out Of Memory Exception while playing with the application for sometime. I looked in to HeapDump using MAT, and also monitored the heap through DDMS. But HeapDump looks good to me and DDMS heap size is well in limit. Still I am getting this Exception.
View 7 Replies
View Related
Apr 18, 2010
I really don't know why it's giving me this error... I load an ImageView with an image of 692kb .jpg, using scroll options, so you can scroll it around... the strange it's that when the mobile it's connected to the VM it's less possible to happen. So...how can I prevent this? is there anyway that I can free memory when starting the app? can I tell the system to free memory before loading the image?
View 6 Replies
View Related
May 21, 2010
I have a really long collection with 10k items, and when running a toString() on the object it crashes. I need to use this output somehow.
CODE:..........
Guide how to increase the heap for and Android application. I don't run the command line.
View 2 Replies
View Related
Oct 2, 2010
I'm having a hard time resolving a crash report. It's an OutOfMemory exception that occurs during the setContentView in the onCreate of my main activity.
I just want to be sure I understood Android LifeCycle well :
1) The onCreate of my main activity is called once and only once during the life time of my application ? Is that correct ?
2) Just like for the big bang, before the oncreate of my activity, nothing exists for that activity, so memory consumption is zero, no objects exists right ?
So what can cause that sometimes, with random framework and devices, I get an OOM exception ? I mean if say my background image is causing this, it should blow up everytime, on every device, shouldn't it ? I mean the result should be reliable.
The background image is a standard jpg : 360*480 weighing 37kb, nothing fancy really :s
The crash report below :
CODE:.....................
View 8 Replies
View Related
Nov 5, 2010
In my app, I am creating a bitmap from its colors code like this :
CODE:................
View 6 Replies
View Related
Sep 17, 2010
I create Android applications for my job. Eclipse is open all day and I am frequently editing XML files for layouts, etc. I find that creating/editing these XML files pushes up the memory use of Eclipse. Eclipse never seems to release any of the memory and eventually Eclipse tells me that there has been some sort of workbench out of memory error and I have to exit. It will not let me save or do much of anything after this point.
Is there a workaround for this? I don't want to have to exit Eclipse and start it up because of this memory issue. Why won't Eclipse free up its memory use? It just keeps going up. I am still having issues with running out of memory, the eclipse.ini suggestions did not fix it.
View 1 Replies
View Related
Jun 10, 2010
memory - after only 2-3 minutes I get Force Close and outOfMemory Error. I have only onCreate (I know, stupid, but I didn't knew for anything else as I started only few weeks ago) and inside I have...
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);
many lines of code...manipulating with SQLite databases...
}
View 10 Replies
View Related
Aug 24, 2010
I have an Android app that in the onCreate() method, preloads a lot of graphics.
When I test my app on my HTC Aria and launch it, it runs fine. However, if I press the back button to exit my app, and then launch the app again, it crashes with an OutOfMemoryError: bitmap size exceeds VM budget. If I then launch the app for the third time (right after it has crashed) it launches fine. Then if I close and re-launch it, it crashes again with out of memory. It continues this every-other-time-crashing pattern forever if I keep trying.
I checked to see what life cycle methods were being called and onStop() and onDestroy() are both being called when I exit the app, yet I have a feeling that something is not yet being cleaned up and that by "crashing" the app when I try to launch it the second time, it somehow free's the memory.
Any thoughts on what could be happening or how to remedy this? Please let me know if you need me to post more info.
Info: My app is fairly simple and only has 1 activity that plays some frame animations.
View 3 Replies
View Related
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
Aug 10, 2010
I have a bitmap that I load from the SD card by allowing the user to choose a picture to display. Once the bitmap is created, I set the Bitmap in an ImageView:
CODE:.........................
This works fine. But, if I change the screen orientation from portrait to landscape, and back again a few times, I always get an OutOfMemory exception.
In onPause, I call mBitmap.recycle(), and then on onResume, I call the above code again to create the bitmap and set the ImageView. Since I'm recycling the image each time, how can I get an OutOfMemory error?
In any case, since that failed, I found a post that said to try using onRetainNonConfigurationInstance() and getLastNonConfigurationInstance(). See post http://stackoverflow.com/questions/3250987/save-cache-when-rotate-device/3252547#3252547. I changed my code to work this way, and I still get an error. Changing the code, I had the call to getLastNonConfigurationInstance() in onCreate(), and removed all code in onPause and onResume. provide some way to simply load an image, and then be able to pause and resume the Activity without running out of memory?
View 3 Replies
View Related
Mar 22, 2010
I have an application which fetches data from server and shows it in different lists in my application. I used the adb shell procrank command to find out the memory usage of my application It takes 10 mb for the UI (I have a single Activity ,but many layout files), And the data which comes from the server is stored in memory arrays for logical representation on UI (As well as database)and it takes 6 mb of the memory .So application's runtime size reaches to 16 mb and then many a times its crashing after that with OutOfMemoryException. Another major problem is that later for the next client release , the data comming from the server will be around 12 mb.. :( :( So i need to do a major restructuring in the App.I beleive that i cannot increase my App size from 16 mb to more So my question here is , can i have two seperate applications , one of which will fetch the data from the server and keep it in memory as well as database and another App will be used for showing the UI and it will do an inter Application communication to fetch the data and display it on the UI in this App. So the 1st App wil be a backgrond App which will handle Server communication as well as data storage , the second App will start this 1st App .
View 18 Replies
View Related
Aug 6, 2009
I wonder why I sometimes get an OutOfMemory Exception in mapView when scrolling around on map and zooming in to the max Zoomlevel? Is this a bug in the Zoomcontrols or MapView Lib?
Here the stacktrace:
CODE:.........................
View 2 Replies
View Related
Aug 25, 2010
I've been trying to make a simple live wallpaper out of a boot animation. So basically i have about 50 .pngs in my drawable folder. I'm able to set the animation to about 10-20 frames and it works great. But once i set it to about 30 frames...I get an OutOfMemory Error. I was hoping maybe someone could take a look at my code and maybe give an example of how I could achieve more frames? That would help so much i've been looking at this for hours > <
Here's my code:..................
And here's a logcat if that'll help at all:
CODE:...............
View 4 Replies
View Related
Jul 23, 2010
I am trying to set a different wallpaper for every home screen, but I get OutOfMemory issues. I have 5 Bitmaps which I am trying to overlay on a wallpaper Bitmap which is 5 times the display width. Using the code below I get OOM. The problem seems to be the first line of code which creates the large wallpaper Bitmap. My question is whether there is a way to do this (i.e. some way that takes up less memory, or someway to allocate more memory?).
CODE:.......................
View 1 Replies
View Related
Apr 21, 2009
I sometimes get bug reports that are caused by an OutOfMemory error. It happens when creating a bitmap, but I am pretty sure that it is not the bitmap size that is the real problem, because the instantiation of those images happens > 100.000 times a day without an error report. Those png images are of 4K size (on disk) anyway.
Those bug reports are very infrequent, but still I would love to get rid of them. I can't reproduce the memory growing over 10 MBs (actually way less) when using the app myself and monitoring the memory consumption in DDMS. I also, at no point in time, cache something or hold on to more than one item (article in my case) at a time, except in one list. There the list caches the visible components, which cannot amount to much too and is default functionality from the Android framework.
..........................
View 3 Replies
View Related
Jan 15, 2010
I have a list of 70 text items with image icons(which are stored in drawables folder).
If I launch application the first time and scroll the list slowly - the exception doesn't occur.
When the application is launched the first time and I scroll the list with 'fling' action the following exception occurs:
COD:.....................
After that, if I kill the application with DDMS, start it again and scroll it with 'fling' action, exception doesn't occur. So the exception arises only if application is installed and launched the first time.
Here is the adapter I use for the list:
CODE:................
Is there a way to avoid the exception? Should I catch the exception and escape the memory somehow?
View 1 Replies
View Related
Nov 5, 2010
In my application I load a couple of images from JPEG and PNG files. When I place all those files into assets directory and load it in this way, everything is ok:
CODE:..................
But when I try to load the exact same images from sd card, I get an OutOfMemory exception!
CODE:..............
This is what I get in the log:
CODE:...........
UPDATE: Tried both of these on real device - it seems that I can't load more than 12MB of bitmaps into whatever is called "external memory" (this is not an sd card).
View 7 Replies
View Related
Sep 29, 2010
Apparently you can't have a file in "assets" larger than 1MB (except for certain file types) because it's considered too large to uncompress. But I'm finding mixed info about how to circumvent this limitation. Some say that you can put the files in "raw" and avoid the limitation but others say that files in "raw" are compressed too.And there's the -0 aapt option that can be used to turn off compression for certain file types, but there's no way to specify aapt options in Carbide. I realize that I can break the file into pieces, but that's error- prone on both ends.And using one of the known uncompressed file types not only confuses things but also runs the risk that the Android PTB will decide to start compressing that file type.
View 6 Replies
View Related
Jul 3, 2010
I want to download an image from the 'net and set it as the users background. This works great over wi-fi, and some 3G networks, but others (T-Mobile UK, for sure) seem to compress the images before sending them. This effect is noticeable when using the browser, too - however, if you long press on an image and save it, when viewing in the gallery it is either not compressed at all, or substantially less so. I want to be able to do this in my own app.I assume it has something to do with the HTTP headers, but of the ones I've modified, none has made a difference.
View 2 Replies
View Related
Sep 17, 2009
I have the following situation. I have a task with the following activity stack -- A - B - C I have a menu item that allows me to start activity D; so my activity stack looks like this -- A - B - C - D Then I could select a menu item that allows me to start an activity C, which would cause my activity stack to look like this: A - B - C - D - C Then I could go back (via the menu item) to activity D, making my activity stack look like this: A - B - C - D - C - D Doing this a few more times, it would wind up looking like this -- A - B - C - D - C - D - C - D - C - D - C - D - C - D - C - D - C - D - C - D - C - D This seems kinda stupid to me. I'd like it to simply re-use an activity, or pop the activity below to be on top (which goes against the nature of a "stack"). So, what I mean is if I had this activity stack: A - B - C - D And I started activity C (from the menu), I would get: A - B - D - C And if I then started activity D (from the menu), I would get: A - B - C - D Is there a way to do this without keeping some global list of activities and doing gross things to them to reorder them?
View 3 Replies
View Related
Sep 29, 2009
I want to avoid softinput specifically in one activity in a very specific case.
When i *long press "menu" button *softkeypad is coming irrespective of the activity.
How can i avoid this? i have tried "stateAlwaysHidden" etc for that activity. But did it work.
Al other cases ok. Just this case* long press "menu" button*.
View 6 Replies
View Related
May 18, 2010
Since yesterday I got an idea running around my mind but I donīt know first if it would work, and then how "hack" it would be.
People who develop audio processing/recording/playback apps for Android know how hard it is to maintain GC away from our critical paths: playing and recording audio. Processing must be as optimized as possible not only to save battery and use less CPU, but also not to create new objects/allocate new memory spaces ... this all to avoid GC at all cost. Well, we have knowledge and this we can handle (mostly). But what about all the other processing that happens from and for user interaction? Media players display images, some apps display ads, ... and sometimes we have to avoid releasing features to the users just to maintain our critical paths free from GC.
Yesterday I stumbled upon an article about remote services and this led me to a doubt: if they can run as a different process, would a GC call from my activity impact the performance of my remote service? I really donīt know how GC works on the Dalvik so this may be a dumb question. If so, I apologize.
You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
View 4 Replies
View Related
Sep 4, 2010
I have a HTC desire and have my hotmail set up in the standard mail app. i have noticed that some of the mail that lands in the junk mail folder on hotmail itself goes straight into me inbox on my phone. can i avoid this at all?
View 3 Replies
View Related
May 6, 2010
I'm traveling to the Bahamas. Does anyone know if i can you my wifi to avoid charges for instant messenger like yahoo and aim and sending and receiving text messages and which app to download for it?
View 2 Replies
View Related
Apr 10, 2010
I just read the article 'Avoiding memory leaks' in android blog written by Romain Guy. http://android-developers.blogspot.com/2009/01/avoiding-memory-leaks.
View 4 Replies
View Related
Apr 6, 2010
When I start my application initially, I get a black screen which stays for a few seconds before my main activity starts. In case of iphone an image with name default is displayed for that split second. I am not sure how to do the same in android. I tried as below in vain
<activity android:name=".Index" android:label="@string/app_name"
android:screenOrientation="portrait" android:theme="@drawable/defaultimage">
<intent-filter> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </activity>
View 1 Replies
View Related
Jun 22, 2010
I need to use some open source code with GPL3. As usual I don't want to open source code for full application.
Now what I understand is if I make two separate process one with my main application code and other as a service or something with Open source library then in that case I have to open source code only for the other one.
Now the question is what is the best way to do so in Android. Suppose My Main App is A Open Source code is B. So A will give some data to B. B will process this and sends data back to A. B may not need to have any UI.
1. Is it possible to install 2 seperate applications / processes from one APK? 2. What is the best way ?Should B be a service? How will be the communication between A and B ? 3. Is it possible to run/call B from A?
View 22 Replies
View Related
Dec 28, 2009
On Android 1.5, using the Allocation Tracker I see that every time I call TextView.setText() with a StringBuilder as first argument, a String gets allocated from the following call stack (first line is last call):
java.lang.AbstractStringBuilder toString java.lang.StringBuilder toString android.text.TextUtils stringOrSpannedString android.widget.TextView setText
I tried specifying the buffer type with setText(strBuilder, TextView.BufferType.NORMAL) but it doesn't change anything.
Is there a way to avoid this allocation?
View 2 Replies
View Related
Jun 8, 2010
I've read this in a few articles, that one should avoid floating point operations within the physics update of a game.
But how do you really achieve this? Surely all half decent games are going to involve this kind of maths?
Does it mean, convert all your variables to int, or use double instead, or simply just cut it out as much as possible?
View 9 Replies
View Related