A memory allocation method, wherein the method is applied to a computer system, the computer system comprises a processor and a memory, the memory comprises at least two rank groups, each rank group comprises at least two ranks, first portions of address information in addresses of ranks in one rank group are the same, there is a mapping relationship between the first portion of address information and a portion of page number information in a physical address of a memory page in the memory; and the method comprises: receiving (S101), by the processor, a memory access request, wherein the memory access request carries a to-be-accessed virtual address; when determining that no memory page has been allocated to the to-be-accessed virtual address, selecting (S103), by the processor, a target rank group from the at least two rank groups based on access traffic of the at least two rank groups; and selecting (S104), by the processor from idle memory pages, a to-be-allocated memory page for the memory access request, wherein the portion of page number information in a physical address of the to-be-allocated memory page is the same as the first portions of address information in addresses of ranks in the target rank group; wherein the selecting (S103), by the processor, a target rank group from the at least two rank groups based on access traffic of the at least two rank groups comprises: obtaining (S102), by the processor, access traffic of ranks in the at least two rank groups; and selecting, by the processor from the at least two rank groups, a rank group to which a rank whose access traffic is less than a first preset threshold and is greater than 0 belongs as the target rank group. receiving (S101), by the processor, a memory access request, wherein the memory access request carries a to-be-accessed virtual address; when determining that no memory page has been allocated to the to-be-accessed virtual address, selecting (S103), by the processor, a target rank group from the at least two rank groups based on access traffic of the at least two rank groups; and selecting (S104), by the processor from idle memory pages, a to-be-allocated memory page for the memory access request, wherein the portion of page number information in a physical address of the to-be-allocated memory page is the same as the first portions of address information in addresses of ranks in the target rank group; wherein the selecting (S103), by the processor, a target rank group from the at least two rank groups based on access traffic of the at least two rank groups comprises: obtaining (S102), by the processor, access traffic of ranks in the at least two rank groups; and selecting, by the processor from the at least two rank groups, a rank group to which a rank whose access traffic is less than a first preset threshold and is greater than 0 belongs as the target rank group. obtaining (S102), by the processor, access traffic of ranks in the at least two rank groups; and selecting, by the processor from the at least two rank groups, a rank group to which a rank whose access traffic is less than a first preset threshold and is greater than 0 belongs as the target rank group. <EOS>