A technique for defragmenting data stored in memory in a computer system
includes the step of creating a table in memory including the locations of
all pointers associated with stored data. The pointers are stored in a
separate block of memory from the table. Data is defragmented only at idle
time. In response to the defragmentation, only the values of the pointers
are updated, while the locations of the pointers and the corresponding
table entries remain fixed. Pointers can be updated using pointer update
methods that are specific to particular classes of objects or using a
generic method for all classes in conjunction with a list of pointer
offsets. Pointer fields may be locating using a bit mask having values
which indicate whether a particular byte or group of bytes in memory
associated with an object include a pointer field.