Generational behavior for the garbage collector

Same as #5227 but living in this repo & squashed.

Well I completely forgot about this. I just added something which looks right but I don't have mingw/msvc so I didn't even compile the code...