I have very short freezes when scrolling a very long list views containing down sampled images (I use BitmapFactory to produce thumbnails in background that are placed in RAM cache but there is still a problem). When I look at the logs, each mini UI freeze corresponds to a garbage collector log, the freed memory can reach 1 MB ! I don't call the gc myself but I guess this is called automatically in the main thread, so it slows my UI. Maybe calling it explicitly in a background thread (and I have one for all network operations) may help, I'll try JP's approach ASAP.
On Dec 24, 11:16 am, freepine <[email protected]> wrote: > Hi JP, > > Yes, I agree to avoid time-consuming tasks in main thread:)What I am saying > is that mostly GC will hold the whole process' execution while collecting > memory, so it might not behave as you assumed even you put it in a separate > thread. > > -freepine > > On Wed, Dec 24, 2008 at 1:37 PM, JP <[email protected]> wrote: > > > My approach is to relief the main thread from any heavy lifting; > > calling web servers, processing data and preparing data structures. > > Calls to web servers should also not be made directly from the main > > thread. All that helps a great deal to keep the app responsive. > > Correction: Is essential to keep the app responsive. You need to > > understand how to build mutex' though. > > Calling garbage collection (in the background thread) is in a way just > > another operation which occurs in background thread processing. I > > stopped worrying about that a long time back. > > JP > > > On Dec 23, 5:58 pm, freepine <[email protected]> wrote: > > > I was thinking that Dalvik GC was the stop-the-world GC. Does it matter > > to > > > call gc manually in a seperate thread or UI thread itself? > > > > -freepine > > > > On Wed, Dec 24, 2008 at 2:49 AM, JP <[email protected]> wrote: > > > > > Depends where it's placed at. I calls to the GC "scattered" all over, > > > > but with discretion. I made a concious design decision to avoid > > > > allocating memory in the presentation layer which is handling user > > > > interactions. I rely on a separate thread to handle all "back end" > > > > activities such as capturing and processing data, and found it is safe > > > > to call the garbage collector in this separate thread at pretty much > > > > any time. Garbage collection in this archiecture is just one other > > > > activity that will not interfere with the user experience, as long as > > > > the overall burden on resources remains within device capabilities. > > > > > On Dec 22, 12:41 pm, Dan Bornstein <[email protected]> wrote: > > > > > On Sun, Dec 21, 2008 at 11:34 PM, Imran <[email protected]> wrote: > > > > > > hey can i use System.gc() in my activity to request for > > garbage > > > > > > collection. > > > > > > will it work () .. will the garbage collector be called ? > > > > > > Yes it will. However, let me warn you that in my experience adding > > > > > explicit calls to System.gc() almost always results in applications > > > > > that perform worse than ones that just let the underlying VM gc as it > > > > > sees fit. > > > > > > -dan --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

