摘要 |
A method and apparatus for reclaiming space on a flash memory device is provided in which valid data is copied from an individually erasable sector on the flash device to a designated memory location. The sector is then formatted or erased and the valid data is returned to the flash device at the next available free space contiguously. A pointer is updated to keep track of the location of the next available recently formatted free space on the flash device. The process is then repeated on each consecutive sector on the flash memory device until all valid data becomes contiguous on one contiguous segment of the device and all free space becomes contiguous on a second contiguous segment of the device. In this manner, the flash memory is defragmented and the largest possible contiguous file can be written to the device. Files can be saved on the flash memory device in contiguous file formats and blocked file formats. During the reclamation and defragmentation routine, the file format of the valid data is preserved. Also, file blocks on a sector which are originally non-contiguous become contiguous after the routine is performed. |