1. A method to defragment a memory for an integrated circuit (IC) card comprising a plurality of files stored in memory portions, each file including a link to at least one other file, the method comprising: detecting a start address of a first free memory portion of the memory; detecting an address of a memory portion following the start address, the memory portion storing a file to be moved; detecting files including links to the address of the file to be moved; moving the file to be moved to the start address of the first free memory portion; and updating the links to point to the start address.