Track MEMORY ALLOCATIONS the Easy Way in C++
The first 500 people who click the link will get 2 free months of Skillshare Premium: skl.sh/thechernoproject5
Patreon ► / thecherno
Instagram ► / thecherno
Twitter ► / thecherno
Discord ► thecherno.com/discord
Series Playlist ► thecherno.com/cpp
This video was sponsored by Skillshare
Пікірлер: 391
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!
@Saje3l
4 жыл бұрын
same here
@danielkrajnik3817
3 жыл бұрын
survivorship bias, even though I love cherno, this is just a survivorship bias
@fallenflame8678
Жыл бұрын
@@danielkrajnik3817 and c++ programmers always have problems with memory
Q&A : Got any plans or words to say about unit testing in c++?
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
"hello world is not gonna use that much memory" lets just hope that the internet doesn't take this as a challenge
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-lx4fo
3 жыл бұрын
This series is so awesome I've watched every video up to this one in a few days
Q&A: How experienced (as programmers) do you think most of your viewers are?
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
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!
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..].
I always learn something new when I watch your videos, thank you for posting these amazing resources.
Thanks a lot for making these videos!! Q&A: Looking forward to a compiling series~
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.
Thank you! You've helped me a lot, your videos are really good, It's very easy to understand what you explain :D
This actually helped me big time. Big thanks Cherno!
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.
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
Q&A: Will you be doing a series on Design Patterns (like Singletons)? What design patterns are used in game engines you work on?
Nice explanation. I like the way you use. encapsulation and Design patterns to create your own examples. Keep the good work!
Thank you so much Yan! You helped me alot to learn C++ !
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... ?
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!
Nice bro, keep on Really help full.
Tysm for being so consistent with c++ .
Great, thank you for sharing your knowledge and experience!
Great stuff as always. Surprised you haven't done move semantics and perfect forwarding so that's my request.
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.
Hey. always loved your videos. Any plans on doing some videos on memory leaks and tools for monitoring them???
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 !
That helps a lot! Thanks. Is there any video about best practices dealing with large amounts of data (like images)?
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.
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?
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!
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.
Thanks for doing great series! How much time do you spend on working on a typical video, at average?
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
Q&A : can you make a video on client side prediction ? And networking in general
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?
oml that keyboard tho :P glad to see you're still uploading after what feels like years lol
At 0:56 you won't write an app that uses alot of memory Google Chrome Devs: Ohh challenge accepted!
super useful! thank you
Great video Cherno !
Q&A : Do you plan on starting your own startup in near future?
Hi, great videos BTW! What's the hot keys for moving and entire line of code up or down???
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?
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. :)
Thank's the Cherno! Cool video tutorial!
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 :)
Very cool video! Thank you!
Your videos are amazing man. Great explanation. Any book recommendations for c/c++ for embedded software? Also have you ever done embedded software?
@harrirahikainen4196
4 жыл бұрын
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 KZread for example
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!!
Can you recommend a book or some steps on how to optimize an algorithm in general. What is your general aproach ?
Спасибо за видосы! Узнаю больше чем от препдов.
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
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
Amazingly useful.
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......
this is so simple but really smart, I'll totally have to remember this
Very nice treatment of interposition from the language level.
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.
This might really be useful in an embedded environment.... however, how might I try it if we already override new for class constructors in order to force static allocation of those classes? (like a Hardware class that there only ever needs to be one of)
What's your stand when it comes to mixing underscore and camel case?
Could you make a tutorial about callback in c++? Thank for your sharing
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!
thank you so much, this is a really useful trick. You are the best
Hello Cherno. Does delete operator taking size params work with built-in types like int ? If not how to count freeing it from heap ?
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.
Hi Cherno! Thanks for your wonderfull videos: them helps me a lot! If i can i've got a questions: i've try such example with an array. Once call delete[] i cannot hit the delete overload function....Tried with overloading delete[] too without any success. The point is, i don't understand why for array ptr the delete is not called! Thanks again for your unbelievable job!
that was amazing
Are there any issues with multi-threading and not using atomic variables/functions to manipulated your metrics?
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!!! :)
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{}
Would you please make a video about multi-threading in c++?
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
You can also use compilers to help you by compiling C++ code with address sanitizer and leak sanitizer flags.
I still use new/delete and new[]/delete[]. Many years ago I wrote a new/delete scanner to find new's' and look for the corresponding delete's'. If it could not find the delete the app would give an error.
When will you do a C++ Video on Exception handling, and why you don't use it?
@ekremdincel1505
4 жыл бұрын
@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.
2 short questions: Are there some situations in std where the "new" keyword is not used, but malloc() is called directly? Such a case you wouldn't detect by overriding the new operator? When freeing the memory and only passing a void*, how does the system know how much memory to free?
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.
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.
Ok, that trick was amazing
wooow this is pretty freaking cool
Q&A please can you explain virtual inheritance?
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
@leZigoute
4 жыл бұрын
Being curious is the answer. Incremental learning. Don't try to learn everything at once but build your skill one step at a time.
How does just adding a second parameter to your own delete function grab the size?
Q&A: Where/how do you get information regarding topics such as this one?
@eddyecko94
4 жыл бұрын
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.
I'm writing audio software. DAWs are unpredictable. This is going to come in handy immediately!
How to overload delete[] for arrays to show memory freed ?
Really nice content
Does the sound of keyboard being record during you demo the coding? Is that your normal typing speed? or it just video post edit process.
Dude You deserve to lead a company!
what companies or job types would require c++, a job type being desktop programmer or database management.
A video on ways to detect or debug memory leaks will be really really beneficial ?
Question: Using new operator automatically triger consruction method of class. You override it and use malloc inside it. Does it run constructor automatically and how?
Q&A : hey. So I've learnt c++ for 2 yrs in high school but, but but it was on 'turbo c' compiler which is like very much isolated from rest or the galaxy and even though I am fairly intermediate level programer in turbo c but I really can't understand anything done outside this compiler ( ican but you know what I mean??) , PLEASE make a video on how to get out of that compiler and what actually I can do with other ones which turbo c can't do🙂
@breeze2440
4 жыл бұрын
Bro i was used to turbo c too cuz that's the only thing on I got taught in school.. but I have recently installed vs and started cherno series,it's too easy... It's been week and now I am out of that turbo shit and the environment in vs feels much more comfortable ♥️
@rupin4004
4 жыл бұрын
@@breeze2440 thankyou for your response, and yes I have also installed vs and codeblocks and I'm now practiceing on them .😊
Please cover the upcoming features in c++20.
Boost library or any other libraries used most in the market ?
is there a version of this vid without the screaming background noise (or is it my MacBookPro)?
Q&A: How can someone get into game engine development? Is it possible to become a game engine developer without gamedev industry experience (just being good at c++)? It feels like 95% of all gamedev jobs today are in Unity so you have to code in c# and not get any experience in c++
Now i am confused, on the string creation it calls the new function too????
what's your opinion on rust and its memory safety model ?