A memory allocation method, comprising: identifying, by a server, a node topology table, wherein the node topology table comprises a connection relationship between non-uniform memory architecture, NUMA, nodes, a connection relationship between a NUMA node and a node controller, NC, and a connection relationship between NCs in the server; generating, by the server, fetch hop tables of the NUMA nodes based on the node topology table, wherein a fetch hop table of a first NUMA node comprises an NC hop count and a quick path interconnect, QPI, hop count of a shortest path through which the first NUMA node is connected to each of the other NUMA nodes, the NC hop count is a quantity of NCs through which the shortest path passes, the QPI hop count is a quantity of NUMA nodes through which the shortest path passes, and the first NUMA node is one of the NUMA nodes; calculating, by the server, fetch priority tables of the NUMA nodes based on the fetch hop tables of the NUMA nodes, wherein a first fetch priority table of the first NUMA node comprises a priority of accessing each of the other NUMA nodes by the first NUMA node, a smaller NC hop count indicates a higher priority of accessing the NUMA node, and for a same NC hop count, a smaller QPI hop count indicates a higher priority of accessing the NUMA node; when the first NUMA node applies for memory, allocating, by the server, memory based on the first fetch priority table, and for a higher priority, more preferentially allocating memory from a NUMA node corresponding to the priority; and wherein the generating, by the server, fetch hop tables of the NUMA nodes based on the node topology table further comprises: reading, by the server, the stored node topology table; calculating, by the server, a shortest path from each NUMA node to each of the other NUMA nodes based on the node topology table, wherein the shortest path is a path with a smallest NC hop count in a preselected shortest path, and the preselected shortest path is a path with a smallest QPI hop count in a path from one NUMA node to another NUMA node; calculating, by the server, an NC hop count and a QPI hop count of each shortest path based on the shortest path from each NUMA node to each of the other NUMA nodes; and forming, by the server, the fetch hop tables of the NUMA nodes by using the NC hop count and the QPI hop count of the shortest path from each NUMA node to each of the other NUMA nodes. identifying, by a server, a node topology table, wherein the node topology table comprises a connection relationship between non-uniform memory architecture, NUMA, nodes, a connection relationship between a NUMA node and a node controller, NC, and a connection relationship between NCs in the server; generating, by the server, fetch hop tables of the NUMA nodes based on the node topology table, wherein a fetch hop table of a first NUMA node comprises an NC hop count and a quick path interconnect, QPI, hop count of a shortest path through which the first NUMA node is connected to each of the other NUMA nodes, the NC hop count is a quantity of NCs through which the shortest path passes, the QPI hop count is a quantity of NUMA nodes through which the shortest path passes, and the first NUMA node is one of the NUMA nodes; calculating, by the server, fetch priority tables of the NUMA nodes based on the fetch hop tables of the NUMA nodes, wherein a first fetch priority table of the first NUMA node comprises a priority of accessing each of the other NUMA nodes by the first NUMA node, a smaller NC hop count indicates a higher priority of accessing the NUMA node, and for a same NC hop count, a smaller QPI hop count indicates a higher priority of accessing the NUMA node; when the first NUMA node applies for memory, allocating, by the server, memory based on the first fetch priority table, and for a higher priority, more preferentially allocating memory from a NUMA node corresponding to the priority; and wherein the generating, by the server, fetch hop tables of the NUMA nodes based on the node topology table further comprises: reading, by the server, the stored node topology table; calculating, by the server, a shortest path from each NUMA node to each of the other NUMA nodes based on the node topology table, wherein the shortest path is a path with a smallest NC hop count in a preselected shortest path, and the preselected shortest path is a path with a smallest QPI hop count in a path from one NUMA node to another NUMA node; calculating, by the server, an NC hop count and a QPI hop count of each shortest path based on the shortest path from each NUMA node to each of the other NUMA nodes; and forming, by the server, the fetch hop tables of the NUMA nodes by using the NC hop count and the QPI hop count of the shortest path from each NUMA node to each of the other NUMA nodes. reading, by the server, the stored node topology table; calculating, by the server, a shortest path from each NUMA node to each of the other NUMA nodes based on the node topology table, wherein the shortest path is a path with a smallest NC hop count in a preselected shortest path, and the preselected shortest path is a path with a smallest QPI hop count in a path from one NUMA node to another NUMA node; calculating, by the server, an NC hop count and a QPI hop count of each shortest path based on the shortest path from each NUMA node to each of the other NUMA nodes; and forming, by the server, the fetch hop tables of the NUMA nodes by using the NC hop count and the QPI hop count of the shortest path from each NUMA node to each of the other NUMA nodes.