filmov
tv
Never free memory yourself! Do this instead (in modern C++)
Показать описание
Arguably this is the most important video to understand how memory is allocated in C++. Even more, we cover not just how it can be allocated manually but how it allows C++ to be so fast as well as how to do it safely in modern C++.
*We cover*
⏺ What memory management is
⏺ Why garbage collection is not the way to go
⏺ What is stack and how it enables quick allocations and de-allocations of small variables
⏺ Why stack doesn't work well for persistent data
⏺ What is a heap and how it is useful to allocate persistent data
⏺ What issues can we expect with manual memory allocation
⏺ How smart pointers allow allocating memory safely
🙏 *Support what I do*
If you believe that free education is a good thing, you would like to see more of it, and you like my way of teaching C++, please consider supporting my efforts. I choose to not hide this course behind a paywall to keep it accessible for others. With your support you show me that teaching for free *is* a viable option. Here are the best options to support me:
🔗 *Links*
⏺ Donald Knuth picture is from Wikipedia
*Contents*
00:00 - Start
00:25 - What is memory management
02:10 - Why C++ is so cool
04:02 - Allocating and freeing memory
05:07 - The stack
06:18 - Stack hands-on example
08:06 - Why not allocate persistent data on the stack
09:42 - The heap
12:37 - Heap hands-on example
13:43 - Issues with manual memory allocation
18:45 - Smart Pointers
Corrections:
8:24 This example has many issues with it: not only this is not _really_ C++ as the dynamically sized C-style arrays are a compiler extension, not part of the language, but it also misses an include for std::byte. This is just to illustrate how we can overwhelm the stack.
#cplusplus #programming #coding #tutorial
*We cover*
⏺ What memory management is
⏺ Why garbage collection is not the way to go
⏺ What is stack and how it enables quick allocations and de-allocations of small variables
⏺ Why stack doesn't work well for persistent data
⏺ What is a heap and how it is useful to allocate persistent data
⏺ What issues can we expect with manual memory allocation
⏺ How smart pointers allow allocating memory safely
🙏 *Support what I do*
If you believe that free education is a good thing, you would like to see more of it, and you like my way of teaching C++, please consider supporting my efforts. I choose to not hide this course behind a paywall to keep it accessible for others. With your support you show me that teaching for free *is* a viable option. Here are the best options to support me:
🔗 *Links*
⏺ Donald Knuth picture is from Wikipedia
*Contents*
00:00 - Start
00:25 - What is memory management
02:10 - Why C++ is so cool
04:02 - Allocating and freeing memory
05:07 - The stack
06:18 - Stack hands-on example
08:06 - Why not allocate persistent data on the stack
09:42 - The heap
12:37 - Heap hands-on example
13:43 - Issues with manual memory allocation
18:45 - Smart Pointers
Corrections:
8:24 This example has many issues with it: not only this is not _really_ C++ as the dynamically sized C-style arrays are a compiler extension, not part of the language, but it also misses an include for std::byte. This is just to illustrate how we can overwhelm the stack.
#cplusplus #programming #coding #tutorial
Комментарии