They should build the LeakCanary logic into the garbage collector
@codingwithmitch5 жыл бұрын
That would make it too easy 😅
@zameelnm23654 жыл бұрын
yeph i thought it too if LeakCanary can detect why can't collect
@samha15136 жыл бұрын
I love how you did the animation for the HEAP and GC. I did not know about the Leakcanary and now that I do, I will definitely use it. Thanks
@codingwithmitch6 жыл бұрын
The animations were done by a fan. I really liked what he did.
@samha15136 жыл бұрын
Yes it was amazing.
@napalm_exe6 жыл бұрын
Was always curious about the term "Memory Leak", now thanks to you I have a better understanding! Thank you for all your awesome content Mitch!
@Rassy_6 жыл бұрын
Excited for more great content 2019 💪🏾
@codingwithmitch6 жыл бұрын
:D
@GAMITECH_RK033 жыл бұрын
Nice content it cleared all my doubts about memory leak and gc Keep it going
@seifeldenehab37634 жыл бұрын
this was really helpful ! thanks mitch ^^
@andrej7536 жыл бұрын
The quality of content you put out is amazing! Keep going!
@dawoodamir20116 жыл бұрын
That is definitely good practicing for not using context in a background thread really helpfull video
@tekenat4 жыл бұрын
Thanks a lot for this. This video helped me understand memory leaks as well as CONTEXTS(which I had been struggling with)
@M1A2_Abrams_MBT3 жыл бұрын
Great video man. Liked and subbed.
@shivamprasad7823 жыл бұрын
Great video. Thanks for the clear illustration.
@kinleyk37592 жыл бұрын
Bro how do you do on phone?
@agungkurniawan40785 жыл бұрын
Hi, Mitch. Good content. Keep up the good works!
@corporateworld7gl6re8h4 жыл бұрын
This was really very helpful to understand memory leaks, thank you very much, please keep going with these kind of awesome contents:)
@b.k41425 жыл бұрын
Great job mitch! when i learn some thing new from mitch i got more energy to learn hard android programming!
@techmarinar3 жыл бұрын
hey man thank you very much , you always doing what I need , thank you
@mformobileapps4 жыл бұрын
you are amazing mitch..
@codinginflow6 жыл бұрын
Are you recording this from inside a box
@codingwithmitch6 жыл бұрын
A Birdbox
@sexchrist99664 жыл бұрын
V. V. G. V. Vv V. v v v v bbbbbbbbBbBbBBbtbtbtbtbtbtbtbtttttbtbBut. . V. V. . V. . B. . . V. V V. V. V. . V. v. ut. But be. Gg. . G. But v. . od. V. V. G g. . . . . . b But v v. V. be. V. V. tbtbt v . V. . G. @@codingwithmitch
@mytubekt5 жыл бұрын
How to give more thumbs up instead of only one! :) Love it, so informative!
@harinarayananv.m9895 жыл бұрын
Simple and to the point, really helpful, thank you for making this video:)
@hotony40925 жыл бұрын
Good illustration. Simple and clear, thanks.
@codinginflow6 жыл бұрын
I have a memory leak every Saturday when I come home from the Pub, amirite? (Just kidding, I don't drink)
@codingwithmitch6 жыл бұрын
Haha. I usually have a couple drinks on Friday with my pals. So this is accurate for me. I got up at 1030 this morning and brain didn't feel good
@babintandukar89175 жыл бұрын
so basically hangover is memory leak ggwp :V .
@davidscammell98234 жыл бұрын
After much vigorous testing, I can conclude writing code on a hangover makes it much more difficult than it needs to be!
@codinginflow4 жыл бұрын
@@davidscammell9823 😆
@CiprianBindiu6 жыл бұрын
Very helpful and educational. Thank you, Mitch.
@michealandretis72433 жыл бұрын
So how is this not causing a crash ? context is garbage collected before asynctask is completed.. effectively null and mContext points to nothing ? or ... ? could you please explain this?
@isahjade19032 жыл бұрын
4:19 The most common way memory leaks occur
@ShivamSharma-kv6bf3 жыл бұрын
I always used this method, now got cleared thanks
@davidscammell98234 жыл бұрын
Great video, thanks Mitch. Looking at Leakcanary I can see they have second version for Kotlin. Will add this to my code!
@smonkey0012 жыл бұрын
Well, to be fair, it's not like your background thread never end. Once it ends, its grabbing to the objects also end, and once the next round of GC kick in and it will be collected.
@rahulabrol22115 жыл бұрын
Thank you so much for explaining this way..it clears all doubts of mine
@bjugdbjk6 жыл бұрын
Excellent Explanation.Good in details.
@sha171874 жыл бұрын
Thanks for this great tutorial! Can you please show the error log for the crash?
@rockson68396 жыл бұрын
Nice ... Please how long have you been using Android studio and Java?
@codingwithmitch6 жыл бұрын
3 years
@uio86a2 жыл бұрын
It's refreshed after using a movie or camera and going to another app, is there any solution?
@AmitVerma-iq3oe6 жыл бұрын
thanks a lot for good content waiting for more
@JoelMathewmatgoogle4 жыл бұрын
Amazing video!
@lucienchu96494 жыл бұрын
So, a memory leak happens when a background threat holds a Context or Activity reference, am I correct? So if I have another normal Java class that holds (requires) a Context or Activity reference but that class does not deal with any background thread, so there would not be any memory leak even though it holds such a reference. Since an object of this class would be gone as soon as the Activity holding that object is gone. Correct me if I was wrong. Because I was so afraid that I manually set the reference to null on each onPause or onDestroy method in an Acticity, in order to make sure the reference would be release :(
@plunkettdog83044 жыл бұрын
Ok just say I have a context object on a background task but then the associated activity is terminated but it cant be cleaned up, I can understand that the app is then using up more resources than it needs to at this point but when the background task finishes won't the memory be able to be reclaimed by the GC? so what is the big deal if memory is taken up for an extra second or two? Wouldn't this only be a problem on long running background threads?
@darrinreed80273 жыл бұрын
How do I deal with graphics memory? I have tried several times to get any memory leaks, but I have only gotten a memory leak a few days ago, but I have noticed that the graphics memory doesn't go down any. I haven't been able to find anything as far as managing the graphics memory.
@exclusiven9406 жыл бұрын
Why do you not have Apps on Playstore...It's kinda like teaching stuff when you don't implement it yourself??
@codingwithmitch6 жыл бұрын
I understand what you're saying. The truth is, I haven't had any ideas I think are good enough to invest 1-2 months developing.
@exclusiven9406 жыл бұрын
CodingWithMitch I'm sorry Mitch Tabian. I wanted to follow your channel with the intent of LEARNING stuff and implementing. You're one of the best at what you do. Please don't take the comment negatively. I want to see things work for you. Please try! What if it does
@codingwithmitch6 жыл бұрын
@@exclusiven940 I definitely will. Just waiting for the right time and the right idea.
@RatneshNavlakhe2 жыл бұрын
Thanks for the video, one question I have is can we Lazy operator instead of WeakReference ?
@sagarprajapati87694 жыл бұрын
@codingwithmitch , Hi can you please make more videos on this topic and also on ANR and High CPU usage topic ?
@georgeclinton27275 жыл бұрын
What if after a while the Garbage collector cleans the memory holding the context object when the activity is destroyed and the weak reference in the AsyncTask is trying to use the context to access a resource for example. Will the App crash? Please help me explain
@anujgoyal52539 ай бұрын
where to get code where leak is happening !
@jimpauloovejera25993 жыл бұрын
How about you use an ApplicationContext? Would you still cancel the async on onDestroy?
@toseefalikhan22976 жыл бұрын
Really helpful!
@amanaggarwal58844 жыл бұрын
Hi mitch, this is a very good tutorial but i am curious 1. if we use LeakCanary then it always shows a notification when there is memeory leak? if we dont want to show these types of notifications to users and want LeakCanary to run in the background for our mess. Can we customize that too?? 2. Cant we use java Finalize() too??.
@codingwithmitch4 жыл бұрын
Don't use leak canary in your production build
@amanaggarwal58844 жыл бұрын
I dont have any company experience. I am learning from you guys(you and codeinflow and more) . Can you tell us more how we gonna code in professional build and he we can stop memory leak and give us some tips what we should do while making a professional build.
@oleksandrgrument79485 жыл бұрын
Good explanation, thanks
@safees31656 жыл бұрын
Great video man! Any chance you could switch to a dark theme? Will definitely help us nite owls
@codingwithmitch6 жыл бұрын
Thanks. I like white sorry friend.
@ben64 жыл бұрын
Doesn't this memory leak stop as soon as AsyncTask is finished? It other words, 5 seconds? You could argue the AsyncTask can be running on for a long time after that. SURE, but then thats the problem: you're running AsyncTask in the background for no good reason. This is a much bigger problem than having reference to the activity since you might be doing some work on that thread and holding resources. TLDR: I believe this video highlights how to program badly with AsyncTask (then fixes it). It doesn't show a real-life case of memory leak.
@user-sankarsana5 жыл бұрын
Very well! Which emulator are you using?
@codingwithmitch5 жыл бұрын
Vysor, a google chrome extension
@Leonzkyhv4 жыл бұрын
It's not all heap ... There is also the stack in relation to memory consumption.
@babintandukar89175 жыл бұрын
so u can just apply this to any one class which extends application class ..?
@SAROJKUMAR-rr1rr4 жыл бұрын
very good explanation on memory leak
@telephon32082 жыл бұрын
firstly heap is data structure. secondly when you instantiate some class you write it to heap, not "take it away FROM heap"
@minarezkalla44033 жыл бұрын
Amazing ,Thanks alot
@robertpeschke7746 Жыл бұрын
So funny to see this video now. "Leak Canary is created by a very well-renowned company called square....". I think you know a lot more about this company now!
@yumyum175 жыл бұрын
Thanks for the video, but the leakcanary is not showing any leaks for me. I used your code from the video and I ran my app on emulator and physical device.
@omkarpawar17416 жыл бұрын
can you create a tutorial for ANR "Application Not Responding" (ANR)
@workmanager20085 жыл бұрын
Not covered all the possible cases
@josephmolina54775 жыл бұрын
Is the Android garbage collector different than Java's?
@medomody2426 жыл бұрын
Very good , and I have a question would you please answer me I made an android app that shows the yearly vacation in a table using sqlite database , and I have the problem of gc because I made a lot of views at the beginning. How can I make the view comes faster because I use a tableview and I add to it textviews. Would you help me ? My name is medo
@codingwithmitch6 жыл бұрын
I'm not going to review your code or help you code, but you can ask me a specific question and I can try to help.
@medomody2426 жыл бұрын
My question is how to load thousands of textviews inside a tableview in a short time without gc affect ? I need only an advice from you Mr
@medomody2426 жыл бұрын
And thank you very much cause really all what you do is helpful and high class
@codingwithmitch6 жыл бұрын
@@medomody242 why not just use a single textview? Then just append all the data to a StringBuilder or something and display it. Or use a recyclerview if there's thousands.
@medomody2426 жыл бұрын
I tried this Mr but I have a big scroll table one column fixed with recyclerview it scroll only one row but I need all to be scrolled
@ankitrajdwivedi9966 жыл бұрын
how to prevent memory leak because of view in previous activity's fragment..????..
@codingwithmitch6 жыл бұрын
Did leak canary tell you it's leaking?
@ankitrajdwivedi9966 жыл бұрын
@@codingwithmitch yes it points to normal relative layout. But I can't find why because that layout is not static and also not accessing in any background process it always on ui thread.
@codingwithmitch6 жыл бұрын
@@ankitrajdwivedi996 Did you instantiate the fragment using the new instance method?
@ankitrajdwivedi9966 жыл бұрын
@@codingwithmitch yes some places I have but in some places adding through the fragment transaction.. both places I have that issue...
@codingwithmitch6 жыл бұрын
@@ankitrajdwivedi996 post a gist containing the code causing an error
@progtom75853 жыл бұрын
Learned a heap, (Pun intended) thanks heaps
@AbdullahKhan-qn6nu4 жыл бұрын
still leaking memory with this approach while loading next activity
@viktorvostrikov96256 жыл бұрын
Wow, just searched in google by recent and this video appeared... I can't use memory profiler in android 3.0 to find memory leaks.. It is so frustrating. Maybe someone does know where is detect leaked activities checkbox?
@codingwithmitch6 жыл бұрын
Use leak canary
@viktorvostrikov96256 жыл бұрын
@@codingwithmitch I did used it but had some strange memory leaks, which I could not figure out to this day. maybe you saw similar messages? stackoverflow.com/questions/53311250/what-does-viewrootlmpl-mattachinfo-means
@codingwithmitch6 жыл бұрын
@@viktorvostrikov9625 I'm not sure. I don't see anything in the code you provided that would explain what Leak Canary is saying.
@himanshukandwal13744 жыл бұрын
Great 😌
@ЕвгенийСокирко-д1в4 жыл бұрын
Cooool...It is so simple
@RenatKaitmazov4 жыл бұрын
The example with AsyncTask shown in the video is too simple and more importantly is outdated. In real life nobody uses it. Nowadays developers use either Rx or coroutines. It would be more relevant and valuable to show an example using these technologies.
@ummelaila4628 Жыл бұрын
Helpful
@dbtechprojects23924 жыл бұрын
setting up LeakCanary as we speak........
@MaisUmSomente4 жыл бұрын
AWSOME
@hamidmahmoodi66904 жыл бұрын
nice, tnx
@robertmaurin3495 жыл бұрын
Application memory à supprimer
@bukunmi63786 жыл бұрын
Nice to see ur face and not hear ur cool voice only 😁.
@mohamamdhassanrezaeitabar36955 жыл бұрын
what's your emulator?
@codingwithmitch5 жыл бұрын
vysor, a google chrome extension
@tamiatyesha15524 жыл бұрын
p
@rahulabrol22115 жыл бұрын
Thank you so much for explaining this way..it clears all doubts of mine