Oct 23 | 7:25 PM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Oct 23 | 7:30 PM |
Emmanuel | has entered the room |
Emmanuel |
Hey Mark
|
Mark M. |
hello, Emmanuel!
|
Mark M. |
how can I help you today?
|
Emmanuel |
Ok, so I have a question regarding memory leaks
|
Emmanuel |
I know that when you declare a Handler as an anonymous inner class of an Activity, you are going to leak it because the inner class holds a reference of its enclosing type
|
Emmanuel |
this happens, in my understanding because all Loopers share the same MessageQueue
|
Emmanuel |
my question is:
|
Oct 23 | 7:35 PM |
Emmanuel |
can you also leak an Activity with an anonymous inner OnClickListener, for example?
|
Mark M. |
not usually
|
Mark M. |
the problem is that the Handler is held onto by something that lives past the Activity
|
Mark M. |
and if there's a way to make the Handler go away, I'm not familiar with it
|
Emmanuel |
I see
|
Mark M. |
so, if you were to put an OnClickListener in a static data member, that would leak the listener and anything it can reach
|
Mark M. |
and so if that's an anonymous inner class, you'd leak the outer class (e.g., the activity or fragment that created it)
|
Mark M. |
but, usually we don't put an OnClickListener in a static data member
|
Emmanuel |
right
|
Emmanuel |
so just passing an anonymous inner OnClickListener, that is not a static member, will not leak the Activity
|
Mark M. |
correct
|
Emmanuel |
thanks
|
Mark M. |
if you have another question, go right ahead -- it's a quiet chat room tonight
|
Emmanuel |
there has been some discussion about this at work, and I wanted a trustful answer, lol
|
Emmanuel |
well I actually wanted to thank you for all your work with the Guide and SO
|
Mark M. |
you are very welcoem
|
Mark M. |
er, welcome
|
Emmanuel |
to give you a bit of perspective
|
Oct 23 | 7:40 PM |
Emmanuel |
I started learning how to code less than 2 years ago
|
Emmanuel |
and now I develop professionally
|
Emmanuel |
actually I am switching jobs in a week or so and moving to NYC
|
Mark M. |
congratulations!
|
Emmanuel |
your book helped me a lot
|
Emmanuel |
hopefully I can go to one of your talks in NYC, if there are any
|
Mark M. |
I am glad that you found it useful
|
Mark M. |
I am taking a bit of a break from speaking after my events in October and November
|
Mark M. |
so I do not have anything scheduled in NYC, sorry
|
Emmanuel |
well, but probably it will be more likely that you will go to NYC than to St. Louis
|
Emmanuel |
hopefully, lol
|
Mark M. |
since I have never been to St. Louis, other than the airport, that's a fair assessment :-)
|
Oct 23 | 7:45 PM |
Emmanuel |
what do you think of Android 5.0? isn't material design too animation intensive?
|
Mark M. |
Material Design is fine, I guess, for Android 5.0+, but I'm not a big fan of trying to emulate it on older devices
|
Emmanuel |
I agree
|
Mark M. |
though the borderless buttons I'm seeing in 5.0 drive me up a wall
|
Emmanuel |
I haven't even really looked into the SDK in detail
|
Gabriele | has entered the room |
Mark M. |
hello, Gabriele!
|
Emmanuel |
I was expecting that Google would have a series of videos to teach us a bit more about Android 5.0
|
Mark M. |
Emmanuel: they will probably release more DevBytes videos in the coming months
|
Gabriele |
hi :)
|
Mark M. |
but let me take a question from Gabriele, and I'll swing back to you in a bit
|
Mark M. |
Gabriele: your turn! do you have a question?
|
Oct 23 | 7:50 PM |
Gabriele |
I have a simple_list_item_single_choice listview with many lines (400-600 ~) and when I fast-scroll the listview, the device lags a bit, can I do something to increase its performance?
|
Mark M. |
that's difficult to answer in the abstract
|
Mark M. |
I'd use tools like Traceview to try to determine where your time is being spent
|
Mark M. |
paying particular attention to your ListAdapter (e.g., getView())
|
Gabriele |
I'm using the holder pattern, don't know if it's important
|
Mark M. |
well, that will help a bit, but you'll want to see if anything related to it is showing up in Traceview as well
|
Gabriele |
I will see inside with traceview then, thank you
|
Mark M. |
also, check LogCat and see if you're getting GC-related log messages while the scrolling is going on (e.g., GC_FOR_ALLOC)
|
Gabriele |
can I run it directly from android studio?
|
Mark M. |
I don't think so
|
Mark M. |
I think you'll have to open the Android Device Monitor, from the Tools > Android menu
|
Oct 23 | 7:55 PM |
Gabriele |
ok, thank you Mark
|
Mark M. |
Emmanuel: your turn! do you have another question?
|
Emmanuel |
Are you going to add Android 5.0 to the Guide?
|
Mark M. |
sure
|
Mark M. |
though, as usual, it will be in pieces
|
Mark M. |
there is stuff from past versions I haven't gotten to either
|
Emmanuel |
will we see some 5.0 on the next release?
|
Mark M. |
I am currently planning on a release in mid-November that will start covering 5.0
|
Mark M. |
and more in future releases, in December and onward
|
Oct 23 | 8:00 PM |
Emmanuel |
great!
|
Mark M. |
but it will not be until 2015 before I get to some of the bigger-ticket items, like RecyclerView
|
Mark M. |
as I have very little time to work on this stuff here in the rest of 2014, due to presentations and training engagements
|
Emmanuel |
I can imagine
|
Mark M. |
if either of you have a question, go right ahead
|
Emmanuel |
are you going to cover dependency injection libs?
|
Emmanuel |
Dagger, more specifically
|
Mark M. |
no, in large part because I am not using them anywhere, so I lack experience in the subject
|
CodeApprentice | has entered the room |
CodeApprentice |
Hello
|
Mark M. |
hello, CodeApprentice!
|
Oct 23 | 8:05 PM |
Mark M. |
CodeApprentice: I'm kinda in free-for-all mode at the moment, so if you have a question, go right ahead!
|
CodeApprentice |
Emmanuel told me you were online. Just wanted to drop in.
|
CodeApprentice |
Not sure that I have any specific questions right now, though.
|
Mark M. |
OK
|
Mark M. |
if anyone has any questions, go right ahead
|
Gabriele |
under Heap, from the emulator, I can read a lot of objects and a big percentage of usage (80-100%)
|
Mark M. |
um, I'm sorry, but I don't know what "under Heap" means
|
Gabriele |
the heap tab inside the monitor
|
Oct 23 | 8:10 PM |
Mark M. |
I haven't been in that in a couple of years
|
Mark M. |
("that" meaning the tab that you're referring to)
|
Oct 23 | 8:20 PM |
CodeApprentice | has left the room |
Gabriele |
do you remember where I can see the time spent, Mark?
|
Gabriele |
I can't find it
|
Mark M. |
everything in Traceview is about the time spent
|
Mark M. |
there is the timeline by thread at the top
|
Mark M. |
there is the call tree at the bottom
|
Mark M. |
poke through the call tree, looking for references to your ListAdapter and/or ViewHolder classes, and see how much time the reported methods on those are taking up
|
Mark M. |
or, look for other things that seem out of place, in terms of the number of calls, the time taken, etc.
|
Mark M. |
there's also a chapter in the book on Traceview, and another on jank, that might be of use in tracking down your problem
|
Oct 23 | 8:25 PM |
Gabriele |
ok, thank you again, Mark
|
Oct 23 | 8:30 PM |
Mark M. |
that is a wrap for today's chat
|
Mark M. |
the transcript will be posted to http://commonsware.com/office-hours/ shortly
|
Mark M. |
the next chat is Monday at 7:30pm US Eastern Time
|
Mark M. |
have a pleasant day!
|
Emmanuel | has left the room |
Gabriele | has left the room |
Mark M. | turned off guest access |