Coding Shorts: Making Sense of Stack vs. Heap

แชร์
ฝัง
  • เผยแพร่เมื่อ 5 ก.ย. 2024
  • This is a different kind of video that I usually make. The topic of how memory is handled in a variety of languages is a key concept every developer should have a handle on. In this quick tutorial, I try and explain how it works. Take a look!
    If you like this video, you might like other videos in my Instructional Videos:
    - • Instructional Videos
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 15

  • @RobertSagoe
    @RobertSagoe 2 หลายเดือนก่อน +1

    Your explanation is clear and concise, making the process easy to understand. Thank you for the details and excellent graphical explanation .. really helpful

    • @swildermuth
      @swildermuth  2 หลายเดือนก่อน

      Glad you enjoyed it!

    • @gandodiallo4146
      @gandodiallo4146 2 หลายเดือนก่อน

      You are the best Shawn

  • @LUNTE1337
    @LUNTE1337 2 หลายเดือนก่อน +1

    Excellent explanation and visualization!

    • @swildermuth
      @swildermuth  2 หลายเดือนก่อน +2

      Glad you liked it!

  • @nickguerra8460
    @nickguerra8460 2 หลายเดือนก่อน

    Nice explanation. It helped clarify a few things. Thank you for your efforts!

    • @swildermuth
      @swildermuth  2 หลายเดือนก่อน

      You are welcome!

  • @kinsondigital
    @kinsondigital 2 หลายเดือนก่อน

    Great explanation!! Love it!

    • @swildermuth
      @swildermuth  2 หลายเดือนก่อน

      So glad!

  • @adsfaedaer
    @adsfaedaer 2 หลายเดือนก่อน

    when the stack pops what happens to a struct - which is a value type - that contains a string. is the string immediately culled (because the struct has been cleaned up) or does it wait around for the GC? - also how many pancakes where consumed after you did this ?

    • @swildermuth
      @swildermuth  2 หลายเดือนก่อน +1

      any reference types that the struct is holding on to will be released to the GC but not disappear immediately. The Struct is a value type but it doesn't promote members of the struct to value types, remember the reference types in the struct are just the addresses of the reference types in the heap. Does that make sense?

    • @heavypeki
      @heavypeki 2 หลายเดือนก่อน

      @@swildermuth Perfectly makes sense. Struct in itself is a value type, but isn't responsible for its own members which could be address pointer.

  • @williamliu8985
    @williamliu8985 2 หลายเดือนก่อน

    Is it able to see if the target is in stack or heap when debugging?

    • @swildermuth
      @swildermuth  2 หลายเดือนก่อน

      I don't see a way, but of course, you can see the type (and infer it's on the stack) - might want to look at C# boxing too (essentially making a reference to a value type so that it becomes a reference type).

    • @williamliu8985
      @williamliu8985 2 หลายเดือนก่อน

      @@swildermuth Thanks! It would be nice if their locations were clearly indicated in the debugger so that programmers don't have to guess about such a basic but important concept.