1. A method comprising: maintaining, by at least one processor, a remembered set for a class set, the remembered set indicating whether instances of the class set are contained in one or more regions in memory, and in which regions in memory the instances are contained; configuring the remembered set to transition between a plurality of possible representations in order to use memory efficiently, the possible representations comprising: (1) an “immediate” representation storing pointers to specific regions in memory where instances of the class set are contained; and (2) a “bit vector” representation comprising a bit for each region in memory that indicates whether at least one instance of the class set is contained in the corresponding region; causing the remembered set to transition from the “immediate” representation to the “bit vector” representation when a number of regions that contain instances of the class set exceeds a specified number; and using the remembered set to perform an incremental garbage collection process for a subset of the regions in memory.