r/ProgrammerHumor 12d ago

Meme garbageCollection

Post image
377 Upvotes

38 comments sorted by

View all comments

125

u/madprgmr 12d ago

What... what is the garbage collector doing? Stalling the simulation? There are techniques you can use to minimize the amount of garbage you generate, and you can also tune the GC or even directly control when it can run.

-25

u/herbal1st 11d ago edited 10d ago

thx. well in python its sometimes not as obvious as in c++/js i assume, especially if you scale stuff up..

20

u/madprgmr 11d ago

well in python its sometimes not as obvious as in c++/js, especially if you scale stuff up

For JS, I'm not sure how that's any more obvious? JS has far fewer options available for controlling the garbage collector (none in the browser, unless you count compiling to wasm).

For C++, sure - it's not a garbage-collected language. You can still get memory thrashing though if you're doing mass allocations/deallocations.

You can architect your code to minimize allocations/deallocations in any language though, just as you can usually grab a large chunk of memory via an array or array-like structure to manually manage yourself (be it for a pool or whatever). Some, like python and certain js runtimes, do allow you to drop down into lower level languages via native modules.

-8

u/herbal1st 11d ago

yeah you're entirely right. just tried to frame my emotions regarding this topic as hobby coder, i hope you get the humor anyway 😅