I have been bamboozled, I thought I was gonna learn how solid waste management companies are created and run, and paid for by local governments and gated communities
@ficolas23 ай бұрын
Goblin mode on
@_modiX3 ай бұрын
whats wrong?
@ficolas23 ай бұрын
@@_modiX Just an Easter egg, try to find it if you are bored hehe
@GavinBogie3 ай бұрын
@@_modiX 3:50 read
@_modiX3 ай бұрын
@@GavinBogie thank you, that's hilarious
@Hellbending2 ай бұрын
Spicy
@addcoding81504 ай бұрын
I think it heavily depends on discipline. There are C-code bases where even Valgrind and other analyzers can't protect you from leaking. But there are others where the lifetime model is thought through and you never have to worry about management. Game devs have memory management for games figured out at this point and found easy patterns for their use case. I wonder if, when web devs put their heads together, we also can find those patterns that make manual mem management easy.
@no_name47963 ай бұрын
The real problem isn't that the program itself doesn't leak, but that gc languages are pratically always safer to memory bugs, which would creat vulnerabilities, which can be exploited by hackers And gc languages (or languages like rust, where memory is handled by the compiler, by forcing certain rules) are in general safer to those type of vulnerabilities, simply because the gc (or borrow checker) are extremely tested and inspected So basically it just comes down to "use what the prog language offers you, because it's 100% gonna be more reliable then whatever code you can produce" Lol, hope you enjoyed my ted talk 🤓
@nashiora3 ай бұрын
@@no_name4796 Garbage collection is definitely not the reason that many garbage collected languages appear to have fewer memory bugs. Having a runtime present to check that things are sane is one such thing, and many garbage collected languages also have some form of runtime. You can do exactly the same as what they're runtime is doing by generating that code from the compiler, or inserting a lightweight runtime in (even C technically does this, since libc does setup and shutdown of some key things, it just can't take it as far because of its design decisions). The way you create/destroy things in these languages is also often far more restricted, giving the runtime (yes, again, the *runtime*) more control over how memory is given out and how it can be used. These exact same guarantees can be done in non-GC, non-"managed" languages; they just historically haven't been done. Rust achieves much of this safety even without the borrow checker, which is a completely separate thing to this part of the issue. It restricts how you create and store memory, and it can easily put bounds checks in its container types or when using primitives. That's just the kind of thing that was put in place during design, which is hard for other languages to retroactively add for compatibility reasons. C++'s standard library should have those guarantees in its public API too, but C++ gives you a *lot* of arbitrary control over memory regardless so you can still break those guarantees if you try. Using "modern" C++ with "modern" data structures gives you exactly the same benefits as GC'd languages or a language like Rust without most of the drawbacks, it just takes discipline to not use the parts that aren't as savory, which yes is a downside. In most cases, it's *really* not hard to create a domain-specific memory management paradigm for your application in a non-"managed"/non-GC'd language, it just takes a little thought and discipline to do right. Programmers coming from a GC'd language or similar just haven't had to think about it at all, or if they have it's in a very different context (see people having to resort to object pooling to avoid massive amounts of allocations that will freeze up the GC, they're *still* having to consider manual memory management and are actively having to work around and *against* the GC in some cases). GC isn't the solution. Rust's borrow checker isn't the solution. Those are additional tools provided by those languages *on top of* other memory safety guarantees done in ways unrelated to what automatic memory reclamation system is in place. Devs in non-managed languages have solved this problem in many different ways, for many many decades, because it's not impossible to solve and it's necessary to do differently for different domains and use cases. GC isn't one-size-fits-all, and neither is the borrow checker. You can do less wrong by default, but it's not the best solution for many people and you end up having to fight it, often also removing many safety guarantees provided by the language in the process. I don't know where I was going with this other than "GC isn't the important thing to talk about here" at the end of the day. Every single language, regardless of its feature set, eventually requires programmers to think about memory manually. If you can build your own safety measures in the process, you don't have to fight those provided by the language or its runtime and accidentally cause more issues.
@shauas42243 ай бұрын
Would you mind sharing some resources on how game dev memory management was "solved"? Would be really curious to read
@raphael.e.diener3 ай бұрын
@@shauas4224I'm sure you can find it by searching on KZbin yourself, but here is the quick summary: There are 3 types of lifetimes: frame bound and persistent over frames and persistent for the game. You don't need to care about deallocation for game persistent assets, since they should exist for the entire program and then get reclaimed by the os. Assets that life for only one frame is also easy. Have an arena allocator that you pass into the functions and allocate on there. If the frame is over, reset the "beginning" pointer back to 0 and you don't even need to wait for the os on the next frame since the buffer will have the right size and be allocated. Frame persistence is a tad more tricky and depends on the game. If your game is simple, simply have a dynamic array/vec for every type of thing you have in your scenes. When it gets more complicated most people create an asset manager which does the same but behind an abstraction. The asset manager itself will persist for your programs lifetime, hence the os will take care of that you could just make it a global, or pass it as an argument if you care about architecture. Those 3 enable you to always free in the same code block where you do the allocation and you pretty much only do allocation in 2 places: the setup routine and the main game loop. This makes things very clear and structured
@My0ldFr13nd3 ай бұрын
I like garbage collection because I'm garbage at coding
@paulkanja3 ай бұрын
****gets collected****
@SlinkyD3 ай бұрын
Trash Dev gang 🫳⌨️🗑
@ridass.71373 ай бұрын
I want to know what my garbage collector is doing while I creep around my home and act like a goblin
@Duckless1373 ай бұрын
Judging you
@nordgaren23583 ай бұрын
Not all strings are stored in the heap. In some languages like C++, there is "Short String Optimization", which puts the string into the string structure itself with a union, if it's short enough. That gets stored wherever the string object is stored, which can be in the stack. C compiler will also put strings in the stack, if they are short enough
@leonss23563 ай бұрын
"you can choose to allocate and free heap memory yourself, but this usually increases the chance of a memory leak" *GC users holding onto references and leaking a shit ton of memory because they refuse to learn how anything actually works
@Nerdimo3 ай бұрын
Go build a web app in C++ or C
@segganew3 ай бұрын
These days, GC is super advanced. ZGC, Java's newest garbage collector, attains constant-time sub-millisecond collection time, and very few pauses.
@mattmurphy70303 ай бұрын
Java has always been at the forefront of garbage collection technology 💪
@ItIsJan3 ай бұрын
depends on the context. e.G: with applications that have very high object allocation rate (eg minecraft server with many players), gc cycles can easily reach a few houndred, if nout thousand MS
@segganew3 ай бұрын
@@ItIsJan not with ZGC
@PreposterousPixel3 ай бұрын
For char* get_name(), wouldn’t a copy of the pointer be passed out of the function, allowing name (which is a pointer to data, not data itself) to be deleted by the compiler? That way there’s still a reference to the result of read_user_input() which would be managed by the larger scope. I think that’s kinda what Swift does with reference counting
@janPiki2733 ай бұрын
1:24 anarchy chess reference
@qcg_kzre3 ай бұрын
amazing video, this taught me a lot about topic of this video
@Quantum_Nebula3 ай бұрын
Would you be willing to do a tutorial on how you make these modern and fancy animated videos?
@tom-delalande3 ай бұрын
I use something called motion canvas. It’s a library created by a KZbinr called @aarthificial who has some excellent tutorials for it.
@Quantum_Nebula3 ай бұрын
@@tom-delalande oh this is wonderful lol thank you sir!
@LambdaCreates3 ай бұрын
1:23 r/AnarchyChess reference? btw I did see something like a chess move rating on the video about the best shell
@ozzy-fr7vj3 ай бұрын
Arena allocation brother
@dvhh3 ай бұрын
Even without going that far, smart pointers are pretty ok
@revengerwizard3 ай бұрын
Mixed mark and sweep, incremental and generational garbage collection?
@somedudenamedanthony3 ай бұрын
Could you possible make a video on how arena/linear allocation works?
@HamzaDeveloper-j1u3 ай бұрын
If you don't make garbage, you don't need a garbage collector! 😌
@tru2thastyleАй бұрын
What does that even mean? 😂
@thezipcreator3 ай бұрын
0:39 this isn't true with all GCed languages; pony for example always runs the GC after a function terminates (unless you run it manually)
@tobzdaman6193 ай бұрын
Thanks for the video, learned a lot :)
@JakobRossner-qj1wo3 ай бұрын
what happened at the end?
@prawnydagrateКүн бұрын
1:35 gold lol
@_modiX3 ай бұрын
2:00 This is what I don't really understand and I was hoping you could explain it to me. If I return some pointer, I cannot free its heap on the end of its scope obviously, but why cannot simply the parent where this pointer is received at free it on its end of its lifecycle?
@notSoAnonyymus3 ай бұрын
You want rust.
@mattmurphy70303 ай бұрын
You can, obviously. It’s just knowing when you need to do this and remembering to do it that’s tricky.
@martindespagna3 ай бұрын
goblin mode activated
@SlinkyD3 ай бұрын
5/7 🤣🥰🙃😊😅🤣🤣 So reckless,I like.
@incrediblemhi3 ай бұрын
🦀
@tru2thastyleАй бұрын
“Big performance cost.” Things like this are over exaggerated.
@hearteyedgirl3 ай бұрын
goblin
@knkootbaoat67593 ай бұрын
interesting heap values 😅. props for no please subscribe, follow ytbers classic during the video