Stack vs Heap Memory - Simple Explanation

2024 ж. 9 Мам.
173 334 Рет қаралды

I take a look at Stack and Heap Memory and how it affects your application. Knowing how memory is handled in your application can help you understand your variables' scopes.
☕️ I don’t accept paid sponsorships and I have turned off mid-video ads. You’re welcome! If you would like to support my channel see: ko-fi.com/alexhyett
📨 Join my free weekly newsletter for advice, technology and more: newsletter.alexhyett.com
🗺️ Backend Developer Roadmap: www.alexhyett.com/backend-dev...
📝 Blog Post: www.alexhyett.com/stack-vs-he...
🎓 RECOMMENDED COURSES (Use code FRIENDS10 for 10% off)
The Complete Web Developer Course - academy.zerotomastery.io/a/af...
The Complete Junior to Senior Web Developer Roadmap - academy.zerotomastery.io/a/af...
Complete SQL + Databases Bootcamp - academy.zerotomastery.io/a/af...
📚 RECOMMENDED BOOKS
Software Development
Clean Code - geni.us/5AEwj2
Clean Architecture - geni.us/yBrTX
Domain Driven Design - geni.us/WiR0Q0x
Design Patterns - geni.us/5ncUt
Developer Hegemony - geni.us/lAXy
Pragmatic Programmer - geni.us/GfNj9
Data Structures and Algorithms Made Easy - geni.us/sqg6kJ
Refactoring - geni.us/ufAP0mE
The Productive Programmer - geni.us/IT9WiN
Pragmatic Thinking and Learning - geni.us/x81A
Test Driven Development - geni.us/HFV52
Microservices - geni.us/8vMA
🚀 MY FAVOURITE TOOLS
Visual Studio Code - code.visualstudio.com/
Obsidian - obsidian.md/
Notion - affiliate.notion.so/alexhyett
⏳ TIMESTAMPS
00:00 Introduction
00:18 Three main parts
00:28 Stack data structure
00:51 Call stack
01:19 Heap differences
01:50 Variable storage rules
01:58 Value types and reference types
02:23 Local variables
02:40 Reference types on heap
02:57 Value types on heap
03:20 Garbage collector
03:53 Exceptions to the rule
04:40 Asynchronous methods
You can check out more of my favourite tools on my website:
www.alexhyett.com/tech/
🔗 MY KEY LINKS
🌍 Blog - www.alexhyett.com/
🐘 Mastodon - social.alexhyett.com/@alex
🧑‍💻WHO AM I
I'm Alex, a Software Developer and KZhead working in the UK. I make videos about software development to help developers with the skills they need to be senior developers. As well as this KZhead Channel, I also write articles on my website (alexhyett.com) as well as write a regular newsletter that contains some thoughts to help aspiring developers.
‼️ DISCLAIMERS
Some of the links in this description are affiliate links, for which I get a small commission, at no extra cost to you 🙂. I appreciate you supporting my channel so I can continue providing you with free software development content!
#coding #programming #developer

Пікірлер
  • These ideas were saved in my head as a sequence of words for the entirety of my undergrad. If 5 short minutes you managed to actually help me understand a huge gap in my understanding. Thank you so much.

    @michaeltheisen@michaeltheisen Жыл бұрын
    • You're welcome Michael, I am glad it helped.

      @alexhyettdev@alexhyettdev Жыл бұрын
    • ​@@alexhyettdev public class Main { String s = "ABC"; public static void main(String[] args) { Main obj = new Main() ; System.out.println(obj.s); } } in this above code String object is created in heap and also of class. So 2 objects in heap. But isn't the string object Abc resides inside class object in the heap?that's why we are calling it obj.s

      @saumyojitdas4212@saumyojitdas42127 ай бұрын
    • Good video very in-depth

      @rembautimes8808@rembautimes88082 ай бұрын
    • i feel the exact same way!! this random collection of words and statements now i feel like concrete concepts in my brain

      @crazychase443@crazychase443Ай бұрын
  • Perfect, really good explanation. Thank you!

    @based6457@based6457 Жыл бұрын
  • Finally a much simpler with actual sample code that explain the whole stack and heap stuff. Now I understand why and when OOM occurs in app, the usual suggestion is to increase heap size but said to be slow or when we do recursion recklessly we get stackoverflow.

    @bitwisedevs469@bitwisedevs4692 ай бұрын
  • hey this is an excellent video! i'd never thought or read about the link between variable scope and memory. thank you so much!

    @csanid1@csanid12 ай бұрын
  • This video actually answered all my questions about how the stack and heap work together. Great explanation!

    @RYANCARNEY-dc2qe@RYANCARNEY-dc2qe5 күн бұрын
  • A nice and concise explanation . Wishing you all the best for better reach of your subsequent tutorials so a lot from community would benefit

    @balajia.t1487@balajia.t14872 ай бұрын
  • This explanation was exactly what I needed! thank you Alex

    @benessilfie@benessilfie Жыл бұрын
    • You’re welcome I am glad it helped!

      @alexhyettdev@alexhyettdev Жыл бұрын
  • The analogy of a stack of books provided much needed clarity for me. I appreciate the video mate!

    @patrickmccarthy7124@patrickmccarthy7124 Жыл бұрын
    • You’re welcome, I am glad it was helpful.

      @alexhyettdev@alexhyettdev Жыл бұрын
  • Alex, you made my day. I would call you one of the best instructors! Your explanations are flawless. You explain perfectly in context. For instance, where you explain why variables are not accessible outside the method.

    @JakeeReacher@JakeeReacher Жыл бұрын
    • Jake, you made my day! Thank you for the lovely comment. I am glad you found it helpful!

      @alexhyettdev@alexhyettdev Жыл бұрын
  • This is an excellent video about how the memory works, I love the last part about asynchronous methods. Thank you for this awesome content. I wish you could speak more about asynchronous functions. 😃

    @alexsal6069@alexsal60693 ай бұрын
  • This is one of the best programming related videos I have ever watched. It cleared up so much of my confusion in C++.

    @kohltonpeterson3287@kohltonpeterson32875 ай бұрын
    • Thank you!

      @alexhyettdev@alexhyettdev5 ай бұрын
  • Wow this was an incredible series of topics, thank you!

    @amalekilawlor2922@amalekilawlor292210 ай бұрын
    • Thanks, I’m glad you enjoyed it!

      @alexhyettdev@alexhyettdev10 ай бұрын
  • Your explanations are immaculate! You'll definitely make it big if you want to. I am glad I caught your channel early at 18.4k subscribers

    @potatopotato4676@potatopotato46763 ай бұрын
    • I appreciate that! Will be making more videos soon.

      @alexhyettdev@alexhyettdev3 ай бұрын
  • Not gonna lie, i cant state enough how explanations like this can massively improve your understanding of why code works the way it does. Just learning to code is one thing, but understanding whats behind all of it and WHY whatever thing actually is happening, can definitly up your game. Im not a pro by any means, but i think stuff like this is very important. The visual presentation also makes it way easier to follow and connect the concepts - so thx for that 😊

    @luminuslux@luminuslux Жыл бұрын
    • Thank you, I am glad you enjoyed the video. I find it helps with remembering everything as well. If you can understand something then it tends to stick in your mind a bit better.

      @alexhyettdev@alexhyettdev11 ай бұрын
  • hell yeah. idk how you did it but that finally made sense. i had to have heard the stack of books analogy before, but this is probably the first time seeing it played out with actual books imma have to watch this again

    @agun214@agun21411 күн бұрын
  • Thanks for this simple and straight to the point explanation

    @timi_t_codes@timi_t_codes10 ай бұрын
    • You’re welcome!

      @alexhyettdev@alexhyettdev10 ай бұрын
  • Reading a book right now that explains this concept rather poorly over 20 pages. You managed to grant me understanding in 5 minutes, and now I can continue reading past the chapter. Thank you, great explanation!

    @scubagoblin@scubagoblin8 ай бұрын
    • You’re welcome! I am glad I could help you understand it. Hopefully more fun than reading 20 pages of that book.

      @alexhyettdev@alexhyettdev8 ай бұрын
  • Dude, that was awesome. You explained what I tried to wrap my head around in college courses, in 5 minutes. ily :)

    @chocolate_Almonds@chocolate_Almonds10 ай бұрын
    • Thank you! 👍

      @alexhyettdev@alexhyettdev10 ай бұрын
  • Such an intuitive and simple explanation!

    @dorianneto2859@dorianneto2859 Жыл бұрын
    • Thank you, I am glad it was helpful.

      @alexhyettdev@alexhyettdev Жыл бұрын
  • Very well explained. Thank you!

    @Mythical_Beastinator@Mythical_Beastinator Жыл бұрын
    • Thank you, I am glad you liked it!

      @alexhyettdev@alexhyettdev Жыл бұрын
  • A hidden gem !!! Thanks you so much, I understand it so much better now !!!!

    @nomymathieu-petrin5672@nomymathieu-petrin5672 Жыл бұрын
    • I am glad it helped!

      @alexhyettdev@alexhyettdev Жыл бұрын
  • That is a great, clear, and easy explanation, thank you.

    @wajdwael8775@wajdwael8775Ай бұрын
  • absolutely brilliant explanation, thanks a lot

    @Freepackman@Freepackman Жыл бұрын
    • Thanks, I am glad it was useful!

      @alexhyettdev@alexhyettdev Жыл бұрын
  • Excellent explanation. Thank you so much.

    @polimorphic13@polimorphic13Ай бұрын
  • The best explanation/animation ever.

    @sonederbr@sonederbr Жыл бұрын
    • Thank you!

      @alexhyettdev@alexhyettdev Жыл бұрын
  • Thank you for easy to understand and great video

    @gantushigsaruul2489@gantushigsaruul24892 ай бұрын
  • Great tutorial, it really helped me! Keep it up👍

    @cmaz6132@cmaz6132 Жыл бұрын
    • Thank you! I am glad you found it helpful.

      @alexhyettdev@alexhyettdev Жыл бұрын
  • Simply love your explanations.. Clean and deep..

    @kasunsaumya3151@kasunsaumya31519 ай бұрын
    • Thank you! 🙏

      @alexhyettdev@alexhyettdev9 ай бұрын
  • Great explanation! Thanks Alex!

    @paulventura3118@paulventura3118 Жыл бұрын
    • You’re welcome!

      @alexhyettdev@alexhyettdev Жыл бұрын
  • Great explanation. I do mostly web development, but I've been getting into low-level programming recently, and your video really helped me reach out into my bucket of programming concepts and rearrange a bunch of previous knowledge I had about computers into something more clear and concise. Thanks!

    @SSn0wx@SSn0wx4 ай бұрын
    • You're welcome, glad I could help!

      @alexhyettdev@alexhyettdev4 ай бұрын
  • This video was very good! I really like the way you explain!

    @MarcoLenzo@MarcoLenzo8 ай бұрын
    • Thank you! I am glad you liked it.

      @alexhyettdev@alexhyettdev8 ай бұрын
  • Really great video! This helped so much

    @gavinmeeker287@gavinmeeker287 Жыл бұрын
    • Thank you I appreciate the kind words. I am glad it was helpful.

      @alexhyettdev@alexhyettdev Жыл бұрын
  • lovely explanation, thank you for this

    @triphazard2906@triphazard2906 Жыл бұрын
    • You’re welcome! I am glad it was useful.

      @alexhyettdev@alexhyettdev Жыл бұрын
  • Thanks for the great explanations!

    @davidjiang7929@davidjiang7929Ай бұрын
  • Loved the explanation !

    @may8128@may8128 Жыл бұрын
    • Thank you! I am glad it was helpful.

      @alexhyettdev@alexhyettdev Жыл бұрын
  • Excellent breakdown!

    @iDeveloper92@iDeveloper929 ай бұрын
    • Thank you!

      @alexhyettdev@alexhyettdev9 ай бұрын
  • Thank you very much i was not able to understand this concept even after reading and watching a lot of videos now i have a good understanding of this

    @i_am_dumb1070@i_am_dumb107011 ай бұрын
    • That’s great! I am glad I helped.

      @alexhyettdev@alexhyettdev11 ай бұрын
    • @@alexhyettdev if possible can you please explain the anonymous function part i didn't get it

      @i_am_dumb1070@i_am_dumb107011 ай бұрын
  • That's good stuff ❤ subscribed

    @billbasdras5568@billbasdras55682 ай бұрын
  • that was a clean description of stack and heap. Never knew about anonymous function being a heap, but it makes sense

    @GG-sw9vm@GG-sw9vm9 ай бұрын
    • Thanks I am glad you liked it 👍

      @alexhyettdev@alexhyettdev9 ай бұрын
  • Fantastic explanation, thanks mate!

    @JanosTech@JanosTech7 ай бұрын
    • You’re welcome! I am glad you liked it.

      @alexhyettdev@alexhyettdev7 ай бұрын
  • Thank you! This was great

    @AXkj3mmy@AXkj3mmy3 ай бұрын
  • you actually help me understand a lot ,thank you sir

    @MrHussien66@MrHussien664 ай бұрын
    • You’re welcome!

      @alexhyettdev@alexhyettdev4 ай бұрын
  • Very nice explanation. Thanks !

    @JHatLpool@JHatLpool2 ай бұрын
  • @Alex Hyett As always, you give the best explanation of whatever programming topics that you cover. Please keep up the great work and keep the content coming. I'm a fan :)

    @mehtubbhai9709@mehtubbhai97093 ай бұрын
    • Thank you, I am glad you like them!

      @alexhyettdev@alexhyettdevАй бұрын
  • Excellent explainer and graphics THX

    @milehighgaragespeedshop1065@milehighgaragespeedshop1065 Жыл бұрын
    • You’re welcome, I am glad you like it.

      @alexhyettdev@alexhyettdev Жыл бұрын
  • amazing, this help me understand everything

    @tannguyen_91@tannguyen_912 ай бұрын
  • Well done! Very good video.

    @ragtop63@ragtop633 ай бұрын
  • Thank you sir. Good Explanation. Please, I wish you make a video on "Why in Java, Do Local Variables Used in Lambdas Have to Be Final or Effectively Final?" and please make the explanations at the memory level too, so we can understand all the mechanics behind it.

    @Tanessok@TanessokАй бұрын
  • This is good. Have learned some things I could not know in a year.

    @johndzikunu9986@johndzikunu9986 Жыл бұрын
    • That’s great I am glad you learned something from it. Thank you for commenting.

      @alexhyettdev@alexhyettdev Жыл бұрын
  • Such a great explanation

    @vfryhn2@vfryhn2 Жыл бұрын
    • Thank you! I am glad you liked it.

      @alexhyettdev@alexhyettdev Жыл бұрын
  • Hey man, awesome awesome tutorial

    @nargesdeypir4579@nargesdeypir45798 ай бұрын
    • Thank you!

      @alexhyettdev@alexhyettdev8 ай бұрын
  • Finally, i now understand the differences between these two. Thank you for the video

    @johnolawale2749@johnolawale27492 ай бұрын
    • You're welcome 😊

      @alexhyettdev@alexhyettdevАй бұрын
  • Create more content, you'll be to a million subscribers within a few short years I have no doubt. Your content is pure gold, thank you for explaining this so clearly.

    @AdrianTregoning@AdrianTregoning8 ай бұрын
    • Thank you 🤞🏻. Regular content will be back again in September. I have had some family commitments that has put a stopper to my videos this month.

      @alexhyettdev@alexhyettdev8 ай бұрын
    • @@alexhyettdev fully understand. Good luck! I quit my full time job as a mechanical engineer to become a programmer/coder of sorts. Bit tough being a student at age 41 but for me I made the decision to ultimately spend more time with my family. Have a super day further.

      @AdrianTregoning@AdrianTregoning8 ай бұрын
  • thank you! very clear

    @juliaclaire68@juliaclaire687 ай бұрын
    • You're welcome Julia, thank you for commenting.

      @alexhyettdev@alexhyettdev7 ай бұрын
  • Learning Redux right now, so very helpful! Definitely subscribing.

    @jacobL1172@jacobL11728 ай бұрын
    • Awesome, thank you!

      @alexhyettdev@alexhyettdev8 ай бұрын
  • Nice video, very helpful

    @hamidouhsemix8940@hamidouhsemix89407 ай бұрын
    • You’re welcome, thanks for commenting.

      @alexhyettdev@alexhyettdev7 ай бұрын
  • My jaw dropped when you explained what happens to variables declared in the stack, I never made the connection between this fact and the scope of variables, thank you soooo much !!!

    @0bsy96@0bsy963 ай бұрын
    • Samee heree, I've never even thought of why we couldn't call variables from different scopes, i just took it for granted this opened my eyes

      @nikolabosevski1435@nikolabosevski14352 ай бұрын
    • I'd be extremely weary of taking this for fact. It is up to the compiler to generate scoping rules, as far as I know. Look into it a bit more.

      @TheHermitProcess@TheHermitProcess2 ай бұрын
  • Thank you very much mate. Clear : )

    @ukaszkiepas57@ukaszkiepas573 ай бұрын
  • Awesome video! Id like to add that in csharp async doesnt always equal multithreading, and since it uses internal statemachine which is a class, asyncs may get allocated on the heap

    @EugeneDaveAstator@EugeneDaveAstator5 ай бұрын
    • Yes it’s a good point!

      @alexhyettdev@alexhyettdev5 ай бұрын
  • that was flawless thanks a million man

    @miladfahimi4787@miladfahimi47872 ай бұрын
    • You're welcome, I am glad you liked it.

      @alexhyettdev@alexhyettdevАй бұрын
  • Great explanation!

    @younesmdarhrialaoui643@younesmdarhrialaoui64311 ай бұрын
    • Thanks! I’m glad it was helpful!

      @alexhyettdev@alexhyettdev11 ай бұрын
  • Man you're a savior thanks for the clear explanation

    @Ali_Pxll@Ali_Pxll5 ай бұрын
    • Thanks, glad I could help

      @alexhyettdev@alexhyettdev5 ай бұрын
  • Thanks for the video

    @alireza.m@alireza.m11 ай бұрын
    • You’re welcome!

      @alexhyettdev@alexhyettdev11 ай бұрын
  • You're great. Thanks

    @Fernando-du5uj@Fernando-du5uj2 ай бұрын
  • How does garbage collection handle memory fragmentation? Is there a heap defrag utility? Do you wipe the heap when a program ends? What is multiple programs / threads run concurrently? Now I need to check the rest of your videos for answers. Thank you for starting my journey.

    @Soupie62@Soupie622 ай бұрын
  • Great video!

    @rafaelstrack5858@rafaelstrack58583 ай бұрын
  • Nice video pal. I love to see a video about boxing and unboxing.

    @sunnypatel1045@sunnypatel10457 ай бұрын
    • Thanks! Sure I will add it to my list.

      @alexhyettdev@alexhyettdev6 ай бұрын
  • Thank you!

    @tibebetech4867@tibebetech486711 ай бұрын
    • You're welcome, I am glad you liked my video.

      @alexhyettdev@alexhyettdev11 ай бұрын
  • this video is gold! wow!

    @shadon_official2510@shadon_official2510Ай бұрын
    • Thank you!

      @alexhyettdev@alexhyettdevАй бұрын
  • neat explanation, ty

    @DiogoSilva-xx8nz@DiogoSilva-xx8nz7 ай бұрын
    • Thank you. Thanks for commenting!

      @alexhyettdev@alexhyettdev7 ай бұрын
  • Amazing explanation, greetings from Chile

    @alejandropoirier6493@alejandropoirier64936 ай бұрын
    • Thank you! Hi 👋 from UK 🇬🇧

      @alexhyettdev@alexhyettdev6 ай бұрын
  • thanks for your video

    @PalasBrown@PalasBrown Жыл бұрын
    • You're welcome, I am glad you liked it!

      @alexhyettdev@alexhyettdev Жыл бұрын
  • Good video. One question: In the case of results from asynchronous methods, once the asynchronous function completes, who cleans up the result in the heap that was left over by the async function?

    @Black_Cats_@Black_Cats_8 ай бұрын
    • Generally they will be cleaned up by the garbage collector in the same way other objects on the heap are.

      @alexhyettdev@alexhyettdev8 ай бұрын
    • @@alexhyettdev thanks for your response

      @Black_Cats_@Black_Cats_8 ай бұрын
  • Incredible. Even though I've been a professional developer for six years, I was having a crisis of confidence tonight because I've worked with languages where I never have to worry about this directly. I was asking myself, "Do I even know anything about computers if I don't know the difference between the stack and the heap?" Five minutes and twenty-seven seconds later, I feel like I have a solid understanding of the difference and I'd be capable of talking about this intelligently. Thank you 🙏

    @tylersmith8245@tylersmith8245 Жыл бұрын
    • I have been a developer for 12 years and I went through exactly the same thought process before making this video. I am really glad it helped you.

      @alexhyettdev@alexhyettdev Жыл бұрын
    • Same here just went through a training where some memory management stuff was covered and I felt like an imposter. This made it all make sense

      @___gg421@___gg421 Жыл бұрын
  • Loved the garbage collector animation. Very nice and funny

    @rembautimes8808@rembautimes88082 ай бұрын
  • thanks dude

    @thankzcomputer@thankzcomputer9 күн бұрын
  • Such a precious channel!!! Instant sub from me 🍻🍻

    @petarkolev6928@petarkolev692815 күн бұрын
  • 3:01 small correction. A const is NOT allocated on the heap. In fact, it's embedded on the call site at compile time (in C#/F#/VB), the reference is removed (you can test this: create a const in another lib, reference and use it in your lib. Compile. Now update the const in the referenced lib and recompile, but do not recompile your lib. You'll see it did not change on the call site). What you probably want is readonly, which, in your example at 3:01, would then be allocated on the heap.

    @Misteribel@Misteribel2 ай бұрын
  • Many thanks to your video, this KZhead is valuable, so I read word by word carefully. And I find at 03:55, about the static variable, which is different from what you mentioned in your flvog (the link you provide in descriptions). In ur flvog, in para "where do static variable live", there you said static variables even if they are value types are not stored on the stack or the heap...need clarify? Thanks.

    @leeeric6292@leeeric629210 ай бұрын
    • Thanks for spotting the discrepancy! I need to update my blog to make things clearer. Basically it is an implementation detail. In C# static variables are part of the MethodTables on the "High Frequency Heap". Which is a special part of the Heap memory for static variables and internal data structures. In C and C++ they are stored on the Data Segment, which is a special part of the memory for storing static variables and internal data structures. :) Sound familiar? If you look up Data Segment and High Frequency Heap they are both in the same place in memory. By the looks of things they are just slightly different implementations of the same thing. There is an old article here that explains it in depth: web.archive.org/web/20140724084944/msdn.microsoft.com/en-us/magazine/cc163791.aspx Jon Skeet also has a good article on it as well: jonskeet.uk/csharp/memory.html

      @alexhyettdev@alexhyettdev10 ай бұрын
    • @@alexhyettdev Thanks for your response and your KZhead.

      @leeeric6292@leeeric629210 ай бұрын
  • Brilliant video

    @lachlankitchen528@lachlankitchen5286 ай бұрын
    • Thank you!

      @alexhyettdev@alexhyettdev6 ай бұрын
  • Nice explanation :)

    @ivandrofly@ivandroflyАй бұрын
    • Thanks 🙂

      @alexhyettdev@alexhyettdevАй бұрын
  • thank you.

    @nobody-dy6ld@nobody-dy6ld11 ай бұрын
    • You’re welcome!

      @alexhyettdev@alexhyettdev11 ай бұрын
  • Great video

    @ronz91@ronz91 Жыл бұрын
    • Thank you!

      @alexhyettdev@alexhyettdev Жыл бұрын
  • Love how clear and concise this was! Subscribing. Just a note, it might be helpful to mention how in C there is no garbage collector and you have to free the memory yourself.

    @rensukiyo@rensukiyo10 ай бұрын
    • Thank you! Yes good point C and C++ (and of course Assembly) don't have a garbage collector. As far as I am aware all the others do but there might be a few exceptions!

      @alexhyettdev@alexhyettdev10 ай бұрын
  • God bless you man.

    @joshuafashe9437@joshuafashe94376 ай бұрын
    • Thank you! 🤩

      @alexhyettdev@alexhyettdev6 ай бұрын
  • Great Vid

    @user-ej8tt6lr2k@user-ej8tt6lr2k23 күн бұрын
  • @4:23 what do you mean by the anonymous function is pushed on top of the stack and not have access to what previous level down? You mean even variables within main?

    @kwaku_2023@kwaku_202324 күн бұрын
  • This video needs to be promoted higher on KZhead. Anyone who wants to learn Rust should start from here before diving into the borrow checker.

    @aelesbao@aelesbao6 ай бұрын
    • Thank you. I am glad it is useful for people learning Rust as well. Some of the C# references might not be applicable but hopefully the rest is. I need to learn rust as well actually!

      @alexhyettdev@alexhyettdev6 ай бұрын
  • you are the king

    @yassinekharkhach4889@yassinekharkhach488910 ай бұрын
    • Thanks man 👑!

      @alexhyettdev@alexhyettdev10 ай бұрын
  • Noice explanation thanks mate

    @harrylyod3402@harrylyod34027 ай бұрын
    • Glad it helped

      @alexhyettdev@alexhyettdev7 ай бұрын
  • Very good video

    @hermanheinz33@hermanheinz33 Жыл бұрын
    • Thank you! I am glad you enjoyed it.

      @alexhyettdev@alexhyettdev Жыл бұрын
  • Can you recommend 2 or more books on memory and data structures?

    @wajdwael8775@wajdwael8775Ай бұрын
  • awesome

    @217-sritejrajulu6@217-sritejrajulu68 ай бұрын
    • Thank you!

      @alexhyettdev@alexhyettdev8 ай бұрын
  • what does "heap has higher overheads" mean...? higher cost? I assume (seeing that little 'watch' with pointer at high) that you mean for example it's slower, because it's more complicated for the "machine code" to add to the heap?

    @Cruz0e@Cruz0e10 ай бұрын
    • Yes higher overheads as in performance. It is slower to add to the heap compared to the stack.

      @alexhyettdev@alexhyettdev10 ай бұрын
  • Hello sir at 3:20 in the video you say that in must run times there is a garbage collector that will clean the memory from the stored memory location after it has finished execution. Not sure if you know but with in C and C++ language we do not have a garbage collector I was told. So in C and C++ we delete pointers manually after block execution. So, Actually C and C++ are not garbage collecting languages.

    @itsurguy7756@itsurguy77563 ай бұрын
  • Great explanation! Thank you! My only bit of feedback would be to stay on the graphic visualizations longer. The constant switching between the visualizations and the shot of you talking is a bit jarring and makes it harder to focus.

    @dflosounds@dflosounds3 ай бұрын
  • thank you

    @WhiteSiroi@WhiteSiroi6 ай бұрын
    • You're welcome!

      @alexhyettdev@alexhyettdev6 ай бұрын
  • very nice video

    @xetz@xetz4 ай бұрын
  • I haven't coded in over a year. I had a dream where I was traversing a world on some quest to explain stack vs heap to all these people getting it wrong, and I knew they were wrong but didn't know why. Soon as I woke up I came here. Now I can sleep at night again. Thanks! 😂 It was an..(Explain you're a nerd without saying you're a nerd XD)... moment.

    @vikingghost117@vikingghost11710 ай бұрын
    • I am glad I can help you sleep at night! 😂

      @alexhyettdev@alexhyettdev10 ай бұрын
  • Can you re-check this one? I think something is incorrect with global or static variables. We basically have 4 segments: Stack, Heap, Code Segment, and Data Segment. Global or static variables, including constants like `const int MAX_AGE = 99`, are not stored on the heap. They are typically stored in the Data segment of the memory, specifically in the initialized data section. The Data segment is a part of the memory that contains static and global variables. These variables are allocated and initialized before the program starts executing. The initialized data section of the Data segment holds variables that have explicit initial values, such as the MAX_AGE constant in your example.

    @chitoan77@chitoan772 ай бұрын
KZhead