I'm not even joking, you're LITERALLY posting videos on problems exactly when I have them. First with singletons, then small string optimizations, and now this lmao Thank you so much for the help!
@Saje3l4 жыл бұрын
same here
@danielkrajnik38174 жыл бұрын
survivorship bias, even though I love cherno, this is just a survivorship bias
@fallenflame86782 жыл бұрын
@@danielkrajnik3817 and c++ programmers always have problems with memory
@pureflame88674 жыл бұрын
Q&A : Got any plans or words to say about unit testing in c++?
@hpsmash773 жыл бұрын
"hello world is not gonna use that much memory" lets just hope that the internet doesn't take this as a challenge
@kaihaolin18384 жыл бұрын
wow, you're still updating the cpp series in 2020.Recently I have comtinued to watch 40 videos on this series. it is awesome ,very nice!
@Nick-lx4fo4 жыл бұрын
This series is so awesome I've watched every video up to this one in a few days
@foomoo10882 жыл бұрын
Nice and straight forward for simple scenarios. Be aware there are a few flavors of new and delete to override (arrays, etc) and also any libraries you link to may bypass your overloaded versions depending on how you build and link them
@andreistefanie4 жыл бұрын
Q&A: How experienced (as programmers) do you think most of your viewers are?
@MO-fg2cm2 ай бұрын
7 months into the industry and learning from cherno
@shahbazp14 жыл бұрын
Q&A: Will you be doing a series on Design Patterns (like Singletons)? What design patterns are used in game engines you work on?
@sireeshaputcha4 жыл бұрын
Q&A: Firstly, thanks a lot for making these videos. You literally helped me get through my entire computer graphics course. I'm trying to become a game developer and have been following your videos on C++ and gamedev for quite a while now. What do you think can help/did help you become so good at game development? How challenging is it to work for any AAA game company? Thanks a ton!
@wz54454 жыл бұрын
Cherno, thank you so much for this series, it helps me so much with understanding c++, this is exactly what I need. The majority of other channels only provide examples without really explaining what and why. Honestly man, respect. And I'm wondering if you could do some videos on design patterns and UML? I was running into it in school but didn't find the lectures very helpful lol
@aliberro4 жыл бұрын
At 0:56 you won't write an app that uses alot of memory Google Chrome Devs: Ohh challenge accepted!
@chicoern2 жыл бұрын
F@ck, I'm new to C++ and lost count of how many times you tough me more C++ than any other forum, book, page, etc.... Awesome content, love it!
@RakeshSolanki1 Жыл бұрын
You showed it the best way. Most of the time it's easy to understand our own code than other's tool and how to use those tools. I like your grounded (stick to the basic) approach.
@perfectionbox4 жыл бұрын
A nice feature of POV-Ray's memory allocator is that blocks can be tagged with a string, making it easy to identify them. Breakpointing operator new or malloc is difficult when there's tons of allocations occurring.
@Ghasakable10 ай бұрын
The implementation of the de-allocation is based on which complier you are using, for clang++ you can pass the flag -fsized-deallocation as it is not implemented yet for GNU GCC g++ its supported by default
@PedroOliveira-sl6nw4 жыл бұрын
Great work! Regarding the Q&A, it's not a question but I'd love to hear about (1) Vectorization and (2) Allocators [freelist, etc..].
@konstantinrebrov6754 жыл бұрын
Q&A: What are your opinions about programming languages like Rust and Go vs C++? Can you make some videos about low level system programming in Windows? I know the Linux system calls, but I want to transition to Windows. Have you ever used Microsoft's Managed C++, and can you make a video about it? What are your favorite APIs for C and C++? What should a "good programmer" know about C and C++ in order to get a job? How many hours each week do you devote to researching about programming, and how do you keep track of all the other tasks you have to do?
@gj9ekdjekray4 жыл бұрын
Thanks a lot for making these videos!! Q&A: Looking forward to a compiling series~
@Yupppi Жыл бұрын
This felt super useful. I learned that just a very simple program of 230 lines, that takes a couple of decimal measurements of a part and calculates a standard deviation based quality key numbers and prints them out wouldn't have fit in like a manufacturing industry machine memory a decade or couple ago. Heck, almost 600 kb for that? To calculate and print out 3 numbers from 8 numbers. We live in the age of luxury. Honestly most automation logic codes inside PLC units are smaller I'm pretty sure.
@andre_40463 жыл бұрын
This actually helped me big time. Big thanks Cherno!
@vijaypatil8734 жыл бұрын
Q&A : Do you plan on starting your own startup in near future?
@davidrees14524 жыл бұрын
Q&A: Do you plan on continuing the expansion of the C++ playlist with more "beginner" tutorials? Such as creating videos about subjects you would possibly cover in a later videos. I am interested in your take on lvalues & rvalues, design patterns, best practices for beginners, how to use threads in your program, etc.
@iamagenius26464 жыл бұрын
Q&A : can you make a video on client side prediction ? And networking in general
@4012814 жыл бұрын
I always learn something new when I watch your videos, thank you for posting these amazing resources.
@MdWahidurRahmanOvi4 жыл бұрын
how did you learn all these C++ stuff, what books did you read, how challenging it is to work on a corporate environment as a C++ developer. What do you need to start applying for C++ entry-level jobs? Thanks and I was a subscriber since you had probably 2k subscribers and now you have 200k, congratulations .
@simeonlazarov56434 жыл бұрын
Q&A: My idea is to show off anything that you use in visual studio (mainly). Maybe 2-3 video and by anything I mean keybinds, tools and so on, everything that help us to write fast and good code. Thank you for the best C++ tutorials on the internet, they are as simple as possible and show anything you need to know just to start writing code.
@dojo2029 Жыл бұрын
Great, thank you for sharing your knowledge and experience!
@zuhail3394 жыл бұрын
Tysm for being so consistent with c++ .
@atrumluminarium4 жыл бұрын
Q&A: Do you have any plans to cover some "tips and tricks" with regards to compute in C++? For example parallel calculations in linear algebra with openmp/opencl/cuda etc
@wolpumba40996 ай бұрын
*Summary* * *Problem (**0:00**):* Memory allocation can be hard to track, especially in large projects or when using external libraries. This can hinder optimization efforts and make debugging more difficult. * *Solution (**3:47**):* Override the global `new` and `delete` operators in C++. * This allows you to intercept all memory allocations and deallocations happening in your program. * You can then add custom code to track allocation sizes, locations, and even print debug messages. * *Benefits:* * *Easy Debugging (**3:47**):* Set breakpoints in the overridden operators to pinpoint the exact locations causing allocations. * *Performance Analysis (**7:30**):* Track allocation sizes and frequencies to identify areas for optimization, like reducing allocations in performance-critical sections. * *Memory Usage Monitoring (**9:52**):* Implement a basic memory tracker to monitor total allocated, freed, and currently used memory in your application. * *Example (**3:52**):* The video demonstrates overriding `new` and `delete` to print allocation sizes and implement a simple allocation tracker. It also shows how this technique can be useful for debugging allocations made by standard library components like `std::string` and `std::unique_ptr`. * *Alternatives (**11:44**):* The video mentions profiling tools like Valgrind and Visual Studio's built-in memory profiler as alternative methods for tracking memory allocations. *Note:* This technique is useful for quickly gaining insights into memory allocation within your own codebase. For more advanced analysis and platform-independent solutions, dedicated memory profiling tools might be more appropriate. i used gemini 1.5 pro
@SuperCiao0002 жыл бұрын
thank you so much, this is a really useful trick. You are the best
@psyience3213 Жыл бұрын
That’s pretty cool. I wrote my own smart pointer class that handles memory allocation deallocation, I should add something to it that tracks total memory usage
@nielsdaemen3 ай бұрын
Our teacher forces us to use all kinds of tools, while this is actually just as good! Thanks!
@yayayayayayayayayay6934 жыл бұрын
The delete operator with size parameter is never called for me, when using gcc or clang. Neither in debug nor release optimization. And it seems it is basically not really supported officialy, the compiler just chooses the non-size-parameter version anytime it wants to.
@PrinceGupta-jo8lo4 жыл бұрын
Thanks a lot, Cherno, I was struggling a lot understanding value references and use of std::move in the codebase of MLPack, but the introduction and hint of how move semantics work really helped a lot.
@alextiga81664 жыл бұрын
Would be nice to mention that this example wouldn't call the constructor like the original "new" operator(same applies to destructor call with the "delete" operator) so the beginners won't wonder why doesn't their code work after they overwrite the "new" and "delete" operators.
@soulimanemammar29094 жыл бұрын
It's always possible to write a memory Allocator that handle and optimize most use cases and fallback to new/delete for extreme cases...most std library function are Allocator friendly
@poolmorosanacona19304 жыл бұрын
Thank you! You've helped me a lot, your videos are really good, It's very easy to understand what you explain :D
@dominicrodriguez74134 жыл бұрын
It would be great to hear about how you learned advanced level programming - not how you started but how you developed the skills to work on highly technical projects like game engines
@leZigoute4 жыл бұрын
Being curious is the answer. Incremental learning. Don't try to learn everything at once but build your skill one step at a time.
@tcholly4 жыл бұрын
you can explain all in a good way, you have a mechanical keyboard, you only need a static sound from the microphone and an indian accent and you're perfect
@isaaclacoba44584 жыл бұрын
Nice explanation. I like the way you use. encapsulation and Design patterns to create your own examples. Keep the good work!
@playerplayer11144 жыл бұрын
Thank you so much Yan! You helped me alot to learn C++ !
@glennstormdesign4 жыл бұрын
LOL, _of course_ you continued to show me what I needed, even whilst I dropped off the earth. Thx; I’ll be able to pick things right back up. :)
@rockwellldreamn58434 жыл бұрын
Very cool video! Thank you!
@Ethan-dm2yz4 жыл бұрын
beg you to make such more videos on "working memory and the C++ programming syntax interrelation". It really makes "sense" for writing absolute and optimized programm. PLEASE.PLEASE.PLEASE......
@nikorasub14104 жыл бұрын
Thanks for you great tutorial , I think your tutorial in more focus on "advanced" C++ topic is a great idea.. when I make interview for jobs, they mainly focus on memory part and not "how do you write this" etc etc Q&A : Do you plan to make video about video game C++ technique use in industry (like managing memory for actor with cache, or display a tons of object by example) ? Please continue your great works !
@svenbtb Жыл бұрын
this is so simple but really smart, I'll totally have to remember this
@АндрейБорисов-и4о4 жыл бұрын
Thank's the Cherno! Cool video tutorial!
@a0zhar2 жыл бұрын
start at: 3:45
@parthlodhia55524 жыл бұрын
Nice bro, keep on Really help full.
@brunooliveirasoares74894 жыл бұрын
Great video, as always! You could make a live with the Q&A... that would be interesting! Q&A: Which literature do you recommend regarding the very bases of computer science, like process, threads, algorithms... ?
@mateuszbahyrycz70034 жыл бұрын
Great video Cherno !
@K9Megahertz Жыл бұрын
Paul Nettle wrote a memory manager many years ago that overwrote new/delete/malloc/free/etc... and tracked all the memory allocations and printed out a nice report of unfree'd memory among other stats at the end of program termination. I think you can still find it online. It was a header file you had to include with every sourcefile you wanted to track. It worked really well, at least for single threaded applications. It didn't play nice with multithreaded code but maybe that could be fixed. I tried many years ago but my Kung Fu wasn't all that good at the time. I might be able to make better sense of it now. Ehh, maybe something I'll revisit at some point.
@user-cc8kb4 жыл бұрын
super useful! thank you
@XxxGuitarMadnessxxX3 жыл бұрын
I'm quite happy to have found this video in google search lol I'm messing around with color tagging in a current project and by using your method here, I noticed that one implementation of a certain function allocates almost 40 times less (a bunch of small allocations with mapping and strings) going from 1936 bytes to 56 bytes compared to the original function I wrote by instead using constexpr const char* for color codes , using string_views, and eliminating the table lookups in the form of the mapping that was taking place. Seriously, thank you for this video! It's useful tips and tricks like these that make me excited to keep on learning =D EDIT: Just watched your small string optimization vid after this one and realized i could just use const std::string instead of constexpr const char* (probs should've been using const char* const instead of constexpr const char* anyways if i'm being honest.. woops lol). I'll say it again until I'm blue in the face - thank you for these videos!!
@FatherOfTheParty4 жыл бұрын
Very nice treatment of interposition from the language level.
@felipecarlin85404 жыл бұрын
More of a personal question, when did your interest in game engine development start? I think this is intriguing, because my interest in it started because of your channel. Thanks for the amazing content!
@QckSGaming4 жыл бұрын
Excellent video as always! Keep on doing this stuff, I couldn't get through uni without you lmao Question arises though: How does it effect performance (especially game engine with many allocations) if you write a bit more code in the overloads? Should you create a separate reference counter class in that case that would do the things for you, like call new etc. without actually overloading the standard functionality?
@alitabrizi98114 жыл бұрын
Hey. always loved your videos. Any plans on doing some videos on memory leaks and tools for monitoring them???
@seditt51464 жыл бұрын
For a Q&A I always wanted to know if your Game Engines, Sparky and Hazel are indicative of the sort of Engines you worked on in your professional work. Did they use far more complex and optimized code or does your work reflect what you seen in your time in the industry?
@popcultureprogrammer21712 жыл бұрын
wooow this is pretty freaking cool
@aquavitale35514 жыл бұрын
Thanks for doing great series! How much time do you spend on working on a typical video, at average?
@roxferesr3 жыл бұрын
This is not working for me unfortunately, the delete(void* memory) method gets called sometimes, instead of delete(void* memory, size_t size). When that happens the memoryAllocated - memoryFreed count is off
@andreibade3 жыл бұрын
How to overload delete[] for arrays to show memory freed ?
@brunodelafontaine16374 жыл бұрын
Your videos are amazing man. Great explanation. Any book recommendations for c/c++ for embedded software? Also have you ever done embedded software?
@harrirahikainen41964 жыл бұрын
I would also appreciate more performance related stuff as I would like to transition to C++ from C in my company. Although game development is closer to embedded than most fields you see represented in KZbin for example
@tonholis4 жыл бұрын
That helps a lot! Thanks. Is there any video about best practices dealing with large amounts of data (like images)?
@anujv29094 жыл бұрын
Do you live in Australia? What happened to the fire there, is it settled down or is it still going? And how is affecting day to day life?
@tonghaoyuan4 жыл бұрын
If you use clang you may want to override both void operator delete(void* ptr) noexcept{} and void operator delete(void* ptr, size_t size) noexcept{}
@puppergump41173 жыл бұрын
9:36 Is there any reference for these function signatures?
@Xxp0r4 жыл бұрын
When will you do a C++ Video on Exception handling, and why you don't use it?
@ekrem_dincel4 жыл бұрын
@Ricardo Santos lol "goto is harmful" cant be a reason for this. Dont use loops if you dont want "goto"s in your compiled program. Exception handling is useful, just do it right.
@arielspalter74254 жыл бұрын
Amazingly useful.
@rufusli70564 жыл бұрын
You can also use compilers to help you by compiling C++ code with address sanitizer and leak sanitizer flags.
@yulyalesheva984 жыл бұрын
Hey, Yan, can you recommend the books for game developer, who knows how to make simple games, but wants to learn more about optimization and lunching it's own game. Thanks
@indradb73774 жыл бұрын
Game design patterns, the book is free on the website of the author
@poolmorosanacona19304 жыл бұрын
You read my mind! I was going to ask about books for learning C++
@yulyalesheva984 жыл бұрын
@@poolmorosanacona1930 are you begginer? I can recommend you some resources if you need it. Cuz I have learning c++ from scratch for a year and I have a good results (I got an internship in gamedev company and it's starting in a month). So let me know
@sriramiyer98404 жыл бұрын
@@yulyalesheva98 I know the basics of c++(took the subject in high school) but don't know how to exactly take it to the next level like creating games and stuff. Do you know any good resources for that? Thanks.
@yulyalesheva984 жыл бұрын
@@sriramiyer9840 sure! I reccomend you to look at Cocos2d-x (3rd version, not the newest 4, cuz it's harder to install without guide). Cocos2d-x it's a game engine that has a lot of guides and the big community. After installing, you should look at official guide (documentation) on their website and try to implement the features from the guide. (Like create sprite and move it, or make your sprite into a physical object). After you've learned that stuff, you will be able to make your own mini simple game. I promise you.
@bopon40903 жыл бұрын
this id fricking helpful. ❤❤❤❤
@ahmadashbat3 жыл бұрын
Dude You deserve to lead a company!
@littleclouds14 жыл бұрын
Q&A: It would be nice if you could give an example of when to use Batch Rendering and Instanced Rendering with the pros and cons. PS: Really looking forward to seeing more of the new office :)
@edugar883 жыл бұрын
Really nice content
@elin43642 жыл бұрын
Realized this doesn't track memory allocated with malloc() though
@breeze24404 жыл бұрын
Q&A :. How ! To Be an average programmer ?
@quaintbear4 жыл бұрын
Спасибо за видосы! Узнаю больше чем от препдов.
@mytech67792 жыл бұрын
I was just screwing around with cout sizeof(x), x.size() and various pointers. Anyway std::string may allocate the 8byte string dynamically [¿ "Cherno" should be 7 ? Maybe an alignment thing. ], but std::string has another 32bytes of local metadata & pointers. std library containers generally bring a fair amount of fix overhead, so hard to recommend for large numbers of small element count. Like it would be better to make a vector of 32B arrays than a vector of std::string if you know your longest string will be less than 32char. An example where it would add up is using a string inside a class and then you make a std::set filled with a million objects; up to 32MB in the ideal case but still an easy 8MB saved with a typical word-length distribution, that's per data field. [rambling a bit here] Really anytime your mean string+32 is equal or larger than your longest expected string, there will be equal or less wasted space in the unused char[] elements than would be wasted with std::string metadata, and the vector of arrays will be faster due to more direct access and cache locality. Mean+8B > largest expected, then the vector of fixed array setup will have lower memory waste than a vector of char*. Although the only real advantage of char* over std::string is saving 24B per string, there is similar indirect access and cache misses. std::array and forward_list are the leanest of the bunch but give up some convenience. Still on amd_64 machines even a pointer is 8B so it is very easy to add a lot of overhead with data structure design even if you aren't sloppy.
@masheroz3 жыл бұрын
How does just adding a second parameter to your own delete function grab the size?
@muhammadtaimourafzal52853 жыл бұрын
that was amazing
@matthewpeterson51594 жыл бұрын
oml that keyboard tho :P glad to see you're still uploading after what feels like years lol
@nfrancisj21224 жыл бұрын
A request! if you're taking requests. It would be super awesome if you could do a Math : Games Edition series...or vlog. Just a talk about what kinda math is helpful/required for engine development. Thx!
@jur91034 жыл бұрын
replacing new with malloc have also downside: no constructors/destructors are called.
@Chris-xn9zm4 жыл бұрын
Q&A: Where/how do you get information regarding topics such as this one?
@eddyecko944 жыл бұрын
Chris I think working with other great developers excite your curiosity too, there are some things you wouldn’t even bother looking into unless your livelihood depends on it.
@SarcTiann4 жыл бұрын
KZbin should obligate to leave a comment if you wanna push "dislike". I personally believe that these kind of tools in the course are great
@DrGreenGiant4 жыл бұрын
Q&A please can you explain virtual inheritance?
@garrettbradley71964 жыл бұрын
What’s your favorite/lease favorite feature coming in c++20?
@lincolnsand51274 жыл бұрын
Ranges are cool
@llothar684 жыл бұрын
For me the favorite are modules and coroutines. Modules will be huge. The least favorite are ranges.
@lincolnsand51274 жыл бұрын
@@llothar68 ranges add lazy evaluation
@newoap4 жыл бұрын
Great stuff as always. Surprised you haven't done move semantics and perfect forwarding so that's my request.
@mang0men14 жыл бұрын
Can you recommend a book or some steps on how to optimize an algorithm in general. What is your general aproach ?
@hanztimbreza62174 жыл бұрын
How do you feel about C++20? Thanks for the videos btw.
@bpeachey14754 жыл бұрын
Hi, great videos BTW! What's the hot keys for moving and entire line of code up or down???
@jonathancerbaro713 Жыл бұрын
Ok, that trick was amazing
@mrbisht86384 жыл бұрын
Boost library or any other libraries used most in the market ?
@juliancruz19274 жыл бұрын
200k followers because you're a great teacher. Can you do some advance videos about ComputeShaders and also some about debugging CPU and GPU series? Pls!!! :)
@techdiver60743 жыл бұрын
I'm writing audio software. DAWs are unpredictable. This is going to come in handy immediately!
@leixun4 жыл бұрын
*My takeaways:* How to check memory usage and print them 9:52
@bluehornet67524 жыл бұрын
I don't understand something... At 6:20, we only have our own memory allocator in the call stack, from our operator new overload. OK, I got that part. And then at 6:40 we see the built-in operator new allocator in the call stack, because even though there was SSO going on, Cherno was in debug mode...and MSVC is like that. But why is the built-in new operator in the call stack for the unique_ptr allocation at 7:22? Shouldn't that be using our operator new overload? I mean, small string optimization isn't in play with our custom Object allocation...so why is the C++ new being called to allocate memory for it? What am I missing?