The invention discloses a memory which comprises an on-chip program area and an on-chip data area that are arranged for a normal working mode, an on-chip program area and on-chip data area exchange enable pin, an on-chip address encoder or an address arbiter module, a first selector, and a second selector, wherein the on-chip program area and on-chip data area exchange enable pin provides an enable signal for exchanging the on-chip program area and the on-chip data area; the on-chip address encoder or the address arbiter module receives the enable signal, and outputs a program area bus accessing to the on-chip program area, and a data area bus accessing to the on-chip data area; the first selector is provided with a selection end for receiving the enable signal, an input end for receiving the program area bus, an input end for receiving the data area bus, and an output end connected with the on-chip program area; and the second selector is provided with a selection end for receiving the enable signal, an input end for receiving the program area bus, an input end for receiving the data area bus, and an output end connected with the on-chip data area. The memory has the advantages of flexible testing, high client code density, and the like. The invention further discloses a memorizing method of the memory.