A data writing method and apparatus and a memory, which are used to write data to a non-volatile storage medium NVM. The method comprises: determining a sample data block of a to-be-written data block from the to-be-written data block (S100); separately comparing the sample data block of the to-be-written data block with N sample data blocks in a preset sample set (S200); determining, from the N sample data blocks, a sample data block having the highest matching degree with the sample data block of the to-be-written data block to serve as a target sample data block (S300); and writing the to-be-written data block to a free address space corresponding to the target sample data block (S400). The method reduces the number of write operations during data writing and thus can solve the problems of high energy consumption and reduced service life of the NVM caused by a large number of write operations during data writing.