y i agree with Eric...Completely.. GC is not able to clean it up... On Fri, Jun 11, 2010 at 6:48 AM, Eric F <[email protected]> wrote: > Look at the dimensions of your images, not the file sizes. Because the > file sizes are the result of PNG compression. But let's assume that's > not the problem. > > First place to look is any static data structure, view, or drawable > that you might be stashing somewhere and preventing the GC from > cleaning it up. Remember that many Android objects will hold an > internal reference to a context or other views which will keep your > entire view hierarchy in memory. So holding a reference to just one of > those could be the entire problem. > > -E > > On Jun 10, 11:00 am, svebee <[email protected]> wrote: >> "if you had a png that was mostly white so compressed very well >> you might have a 200KB png file that actually is using 6MB of RAM on >> your device" - I didn't know it can use so much space :/ >> >> About 90% of images (in total application, about 60% of them (this one >> 1KB) are used per activity, so I would say approx. 50KB per activity) >> are 1KB (or less), 5% are 10-60KB and 5% are 1-5KB so I think image >> size isn't a problem. >> >> So I'm pretty sure it's A) but how to solve it? And yes, I'm >> constantly switching between two-three activities (and I disabled >> rotation for some other reasons). >> >> On Jun 10, 7:20 pm, Eric F <[email protected]> wrote: >> >> >> >> > First you need to figure out what is taking up all the space in your >> > memory as well as what is causing the OOM. Like is OOM caused when you >> > switch between two activities over and over again? or if you rotate >> > the phone over and over causing the activity to be re-created over and >> > over. In which case you are probably leaking a context. Or are you >> > running out of memory because you are loading just too many images? I >> > don't think you've really given us enough information to help. If you >> > use DDMS to inspect your heap, what's taking up all the space? If it's >> > images, how big are the images? Remember in order for them to be drawn >> > they need to be *uncompressed* into device's RAM. at say 24 bits per >> > pixel, if you had a png that was mostly white so compressed very well >> > you might have a 200KB png file that actually is using 6MB of RAM on >> > your device. It's just too big, and you might not think about it >> > because if you come from a desktop PC mindset it's just a 200KB png >> > file in your mind. At this point I am guessing that either: >> >> > A) you are leaking a context so the images aren't being recycled >> > B) your images are too large uncompressed >> >> > But without more information it's hard to be sure >> >> > -E >> >> > On Jun 10, 7:28 am, svebee <[email protected]> wrote: >> >> > > hello, as I'm beginner in Android I have problem with 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... >> >> > > } >> >> > > inside main XML layout I have many images, small, big (background) and >> > > so on...How can I on every onCreate "delete" all content from memory >> > > that was before in it - so when I open activity again, it deletes all >> > > images and everything out and insert the new (old) one inside. >> > > "Little" awkward but that's only thing I have on mind. >> >> > > Also, inside "many lines of code" I don't declare any images! >> >> > > Or simply, how can I "bypass" outOfMemoryError? Do I have to do >> > > something like this? >> >> > > �...@override >> > > public void onCreate(Bundle savedInstanceState) { >> > > super.onCreate(savedInstanceState); >> >> > > BitmapFactory.Options options=new BitmapFactory.Options(); >> > > options.inSampleSize = 8; >> > > Bitmap buildingBitmap = >> > > BitmapFactory.decodeResource(null,R.drawable.background,options); >> >> > > if (buildingBitmap != null) >> > > { >> > > buildingBitmap.recycle(); >> > > System.gc(); >> > > buildingBitmap = null; >> > > } >> >> > > setContentView(R.layout.main); >> >> > > many lines of code...manipulating with SQLite databases... >> >> > > } >> >> > > or...? Also on other activity is everything "the same" except I have >> > > multiple overlays, how can I "erase" (recycle) them also? Thank you >> > > for any help. >> >> > > *currently, I'm not searching for fastest, most "correct" or better >> > > solution, I just want something that it's not crashing all the time > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en
-- With Regards, Chetz -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

