The invention discloses a kernel-module
memory management method for preventing memory leaks and multiple memory releases, and the method comprises the following implementation steps: 1) establishing an array of records; 2) when a kernel module requires a
system to allocate memories, adding memory allocation records associated with the allocated memories into the array of records; 3) when the kernel module requires the
system to release memories, searching memory allocation records associated with the memories to be released in the array of records, if the associated memory allocation records exist, executing memory release, and cancelling the memory allocation records; and if the associated memory allocation records do not exist, issuing an alarm of 'multiple releases'; and 4) when the kernel module exits, scanning the array of records, if the array of records still has memory allocation records, releasing the memories associated with the memory allocation records one by one according to the memory allocation records, and finally, clearing the array of records. By utilizing the method disclosed by the invention, the kernel modules can be prevented from having the phenomena of memory leaks and multiple memory releases; and the method has the advantages of
good memory allocation capability, low congestion degree of an
operating system, less occupied resources, small memory-
footprint, and good adaptability.