r/ProgrammerHumor • • Oct 07 '26

Meme minecraftException

Post image
9.3k Upvotes

830 comments sorted by

View all comments

Show parent comment

17

u/Bubbaluke Oct 07 '26

Pretty much nailed it. Garbage collection runs periodically, often without being told to, which could cause hitches.
It can also be turned off and run manually, or not run at all. At least in python.

1

u/rosuav Oct 07 '26

It's worth noting that Python's gc module (the part that lets you turn things on and off) is only about the cycle detector, and most garbage is caught by the much simpler reference counter. (For the pedantic, this is true in current versions of CPython, and other implementations may work differently.) You can't normally disable the refcounting GC, although if you hack on the code to stub out the DECREF operation, you'll quickly see how much memory it can eat...

2

u/Bubbaluke Oct 07 '26

Neat, I’ve only ever changed it briefly in micropython, where it kept interrupting a sound I was trying to play.

1

u/rosuav Oct 07 '26

Makes sense. If you're only playing a sound for a short time and then it falls silent, disabling the cycle detector for that time would be a good way to prevent unexpected pauses, and any memory left allocated during that time can be disposed of once you're done playing the sound.

2

u/Bubbaluke Oct 07 '26

The real solution would have been to switch to c lol, but this was an intro class