CN102103541B - Kernel-module memory management method for preventing memory leaks and multiple memory releases - Google Patents

Kernel-module memory management method for preventing memory leaks and multiple memory releases Download PDF

Info

Publication number
CN102103541B
CN102103541B CN2011100478005A CN201110047800A CN102103541B CN 102103541 B CN102103541 B CN 102103541B CN 2011100478005 A CN2011100478005 A CN 2011100478005A CN 201110047800 A CN201110047800 A CN 201110047800A CN 102103541 B CN102103541 B CN 102103541B
Authority
CN
China
Prior art keywords
memory
record
array
memory allocation
array location
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN2011100478005A
Other languages
Chinese (zh)
Other versions
CN102103541A (en
Inventor
秦莹
戴华东
吴庆波
刘晓建
孔金珠
颜跃进
董攀
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
National University of Defense Technology
Original Assignee
National University of Defense Technology
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by National University of Defense Technology filed Critical National University of Defense Technology
Priority to CN2011100478005A priority Critical patent/CN102103541B/en
Publication of CN102103541A publication Critical patent/CN102103541A/en
Application granted granted Critical
Publication of CN102103541B publication Critical patent/CN102103541B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Techniques For Improving Reliability Of Storages (AREA)

Abstract

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.

Description

Prevent the kernel module EMS memory management process that internal memory is revealed and internal memory repeatedly discharges
Technical field
The present invention relates to the EMS memory management process of operating system nucleus module, be specifically related to a kind of EMS memory management process that kernel module generation internal memory is revealed and repeatedly internal memory discharges the kernel module of fault that prevents to have in the operating system standalone feature.
Background technology
Operating system nucleus is the system that realizes multiple function, and the required extended attribute of autonomous behavior that function is intrinsic and kernel system makes modularization become the important composition method of operating system nucleus.Usually kernel is made up of the module of a plurality of completion difference in functionalitys, and each module has independent entrance and exit, has the control stream of closed loop.Internal memory is the most rare resource in the kernel system operational process; It is operating system nucleus satisfies unlimited application demand with the limited memory resource main method that dynamic on-demand distributes; Intrasystem each functional module obtains through the memory allocation function that the kernel internal storage management system provides at the partial memory that operational process needs; This partial memory discharges when requiring module to withdraw from, and the part of module program is ignored memory discharge operation makes the internal memory that is not used still be free on outside the kernel memory management, causes the internal memory leakage problem; The serious memory source that hinders effectively utilizes, and causes system performance to descend.On the one hand, the part of module program can repeatedly discharge same internal memory, causes the confusion of memory system in addition, and very the person causes the collapse of system.As shown in Figure 1; Kernel module is owing to being started this kernel module life cycle by the operating system load operating, kernel module for the specific function of accomplishing oneself needs Request System storage allocation as required, uses internal memory to accomplish the The Logic of Tasks of specific function in life cycle then; After using internal memory, internal memory is discharged go back to system; After kernel module was accomplished the mission of oneself, system unloaded kernel module at last, thereby stopped the life cycle of kernel module; A period of time in the operational process of kernel module can be used internal memory, and using up release back internal memory can be used by other modules.As shown in Figure 2; Kernel module is owing to started this kernel module life cycle by the operating system load operating; Kernel module when accomplishing the specific function of oneself as required from operating system application internal memory; After using internal memory kernel module repeatedly the invoke memory releasing operation same internal memory discharged back in the system, internal memory takes place repeatedly discharge fault, cause the confusion of kernel module internal storage management system.As shown in Figure 3, in life cycle kernel module when accomplishing own specific function as required from system's application internal memory, but do not have the invoke memory releasing operation it returned the kernel system at the internal memory kernel module of finishing using afterwards.After kernel module withdraws from, need not use the internal memory of previous application, but this piece internal memory uses still can't for other modules of kernel, this situation is called internal memory and reveals.
Operating system is generally come internally to deposit into row through the garbage reclamation algorithm and is reclaimed.The garbage reclamation algorithm is that a kind of centralized internal memory is revealed solution in the software systems; Main thought is: system moves independently garbage reclamation thread; When system is idle; This garbage reclamation thread is located all at the internal memory that uses from the root collection of system, and the internal memory that is not used in total memory pool is reclaimed.Though the garbage reclamation algorithm can be realized the internal memory of asynchronous non-precision and reclaim, because the operation of garbage reclamation thread is subject to the busy not busy degree of system, still can't thoroughly solve the internal memory leakage problem.
Summary of the invention
The technical matters that the present invention will solve is to provide a kind of kernel module generation internal memory that prevents to reveal with repeatedly internal memory discharges, the internal memory station-keeping ability is good, the busy not busy degree of operating system is low, take the kernel module EMS memory management process that internal memory is revealed and internal memory repeatedly discharges that prevents that resource is few, memory footprint is little, adaptability is good.
In order to solve the problems of the technologies described above, the technical scheme that the present invention adopts is: a kind of kernel module EMS memory management process that prevents that internal memory from revealing and internal memory repeatedly discharges, and implementation step is following:
1) sets up the record array that is used to write down this kernel module Memory Allocation record;
2) when kernel module Request System storage allocation, in said record array, add the Memory Allocation record that is associated with storage allocation;
3) when kernel module Request System releasing memory, in said record array, search and the Memory Allocation record of treating that releasing memory is associated, carry out internal memory release and delete this Memory Allocation record if the related Memory Allocation of existence writes down; Do not discharged the internal memory do not applied for, situation wrong or that repeatedly discharge has taken place to discharge if do not have related Memory Allocation record then show.
4) when kernel module withdraws from, the sweep record array if still leave the Memory Allocation record in the record array, then discharges according to the Memory Allocation record internal memory that it is related one by one, and the final record array of removing.
Prevent that as the present invention internal memory from revealing and the further improvement of the kernel module EMS memory management process that internal memory repeatedly discharges:
Said record array comprises at least one extendible array location; Said array location is made up of the expansion slot that a plurality of tracks that are used for the stored memory assignment record and are used to expand array location; Only comprise an array location in the initial record array of setting up in the said step 1); Said step 2) when the lazy weight of the track of an array location during with the stored memory assignment record, the array location that makes new advances through the expansion slot expansion comes the stored memory assignment record in.
Said track is made up of first pointer field that is used for the stored memory positional information and first status field that is used to store current record groove user mode information; Said expansion slot is made up of second pointer field that is used for storing next array location positional information and second status field of the extended mode information of user mode information that is used to store current array location track and current array location; The state of said first status field comprise use with do not use two states, the state of said second status field comprise track be empty, track is full and array location has been expanded three kinds of states.
When adding the Memory Allocation record said step 2), second status field of at first reading the expansion slot of first array location; Carry out judgment processing to second status field then; If the track that current array location is still free; Then the Memory Allocation record is write empty track, if there is not empty track after the array location write memory assignment record again, then second status field with expansion slot is labeled as full; If the track of current array location is full, then set up new array location, second status field and the new array location foundation of expansion slot in the current array location is related, then Memory Allocation is write down first the empty track that writes new array location; If the expansion slot of current array location has been expanded the array location that makes new advances, then with next array location as current array location, return above-mentioned second status field that is directed against and carry out judgment processing.
In the said step 3) when carrying out internal memory and discharge; At first search and wait to discharge content associated Memory Allocation record at all array locations of record array; Carry out judgment processing according to first status field that finds Memory Allocation record corresponding record groove then; If first status field is user mode, then stops inquiry and wait to discharge content associated Memory Allocation record; If first status field is a unused state; Then continue to search and wait to discharge content associated Memory Allocation record; If find then continue to return above-mentioned first status field that is directed against and carry out judgment processing, otherwise stop inquiry and wait to discharge content associated Memory Allocation record.
Deletion Memory Allocation record is meant that with this Memory Allocation record mark be unused state in the said step 3); Said searching Memory Allocation when record; If find Memory Allocation record and this Memory Allocation record to be marked as unused state, then the warning message that internal memory discharges takes place repeatedly in output; The sweep record array of said step 4) is first status field that is not eliminated to Inuse through searching; If there is first status field of Inuse; Show that then the internal memory leakage exists; The free function internal memory that it is related according to Memory Allocation record calling system discharges one by one then, and the warning message of internal memory leakage takes place for final removing record array and output.
The present invention has following advantage:
1, the present invention can prevent effectively that same internal memory record from taking place repeatedly to discharge; Even kernel module is not asked releasing memory, the execution in step releasing memory after still can withdrawing from through kernel module can effectively prevent the internal memory leakage; Do not need special thread to safeguard; Do not rely on the busy not busy degree of operating system, can solve the memory management problem of kernel module in the operating system, have module memory and reveal station-keeping ability; Not only can detect the memory overflow situation that whether exists; Can also confirm the address of leak memory, and have the function that prevents to discharge invalid internal memory to have internal memory and reveal that station-keeping ability is good, the busy not busy degree of operating system is low, take the advantage that resource is few, memory footprint is little, adaptability is good.
2, the record array comprises at least one array location; Array location forms extendible array chain structure through expansion slot, and therefore use is very flexible, both can satisfy the record economy of the little kernel module of memory footprint; Also can guarantee the record demand of the kernel module that memory footprint is big; Can detect the internal memory of multiple module and reveal, effectively satisfy the needs of operating system nucleus availability, have the advantage that the resource of taking is few, memory footprint is little, adaptability is good.
Whether 3, track comprises first status field, therefore can conveniently detect to exist internal memory release applause repeatedly takes place through reading the state that first status field obtains track;
4, expansion slot is made up of second pointer field and second status field; Second status field is used to store user mode and the status information of next array location of the track of current array location; The information that therefore can conveniently realize current array location is obtained and the searching in regular turn of all array locations; Search efficiency is higher, and station-keeping ability is better.
5, when this Memory Allocation of deletion record with this Memory Allocation record mark for deleting; When the Memory Allocation that finds and treat releasing memory to be complementary record and this Memory Allocation record have been changed to delete flag; Then the warning message that internal memory discharges takes place repeatedly in output, and the repeatedly internal memory of kernel module that can effective monitoring operating system discharges information; Still have the Memory Allocation record if find during the sweep record array; Then the warning message that internal memory is revealed takes place in output; Thereby can conveniently locate kernel module the failure message that internal memory discharges and internal memory is revealed taking place repeatedly, is convenient to the kernel module of operating system is improved.
Description of drawings
Fig. 1 is the normal schematic flow sheet of carrying out of prior art kernel module;
Fig. 2 carries out for the prior art kernel module and produces repeatedly the flow process principle schematic that internal memory discharges;
Fig. 3 carries out for the prior art kernel module and produces the flow process principle schematic that internal memory is revealed;
Fig. 4 is the schematic flow sheet of the embodiment of the invention;
Fig. 5 is the structural representation of the record array of the embodiment of the invention;
Fig. 6 is the structural representation of the track of the embodiment of the invention;
Fig. 7 is the structural representation of the expansion slot of the embodiment of the invention;
Fig. 8 is the state variation synoptic diagram of the track of the embodiment of the invention;
Fig. 9 is the state variation synoptic diagram of the expansion slot of the embodiment of the invention;
Figure 10 is the initialized schematic flow sheet of record array of the embodiment of the invention;
Figure 11 is the record modification schematic flow sheet of the embodiment of the invention when Memory Allocation;
Figure 12 is the record modification schematic flow sheet of the embodiment of the invention when internal memory reclaims.
Marginal data: 1, array location; 11, track; 111, first pointer field; 112 first status fields; 12, expansion slot; 121, second pointer field; 122, second status field.
Embodiment
As shown in Figure 4, the implementation step that prevents the kernel module EMS memory management process that internal memory leakage and internal memory repeatedly discharge of the embodiment of the invention is following:
1) sets up the record array that is used to write down this kernel module Memory Allocation record;
2) when kernel module Request System storage allocation, in the record array, add the Memory Allocation record that is associated with storage allocation;
3) when kernel module Request System releasing memory, in the record array, search and the Memory Allocation record of treating that releasing memory is associated, carry out internal memory release and delete this Memory Allocation record if the related Memory Allocation of existence writes down;
4) when kernel module withdraws from, the sweep record array if still leave the Memory Allocation record in the record array, then discharges according to the Memory Allocation record internal memory that it is related one by one, and the final record array of removing.
In the present embodiment; In kernel module existing systems Memory Allocation logic, added step 2); In kernel module existing systems internal memory release logic, added step 3); When kernel module withdraws from, increased step 4), thereby can prevent effectively in the operating system that kernel module takes place from be loaded into the process that withdraws from that internal memory is revealed and internal memory repeatedly discharges.
As shown in Figure 5; The record array comprises at least one extendible array location 1; Array location 1 is made up of the expansion slot 12 that a plurality of tracks 11 that are used for the stored memory assignment record and are used to expand array location 1; Only comprise an array location 1, step 2 in the initial record array of setting up in the step 1)) in when the lazy weight of the track 11 of an array location 1 during with the stored memory assignment record, expand the array location 1 that makes new advances through expansion slot 12 and come the stored memory assignment record.Track 11 is used for stored memory positional information and current record groove 11 user mode information; Expansion slot 12 is used for next array location 1 positional information of store storage and the user mode information of current array location 1 track 11 and the extended mode information of current array location 1, and wherein core position information and next array location 1 positional information are the internal memory pointer.
Like Fig. 6 and shown in Figure 7; Track 11 is made up of first pointer field 111 that is used for the stored memory positional information and first status field 112 that is used to store current record groove 11 user mode information; Expansion slot 12 is made up of second pointer field 121 that is used for storing next array location 1 positional information and second status field 122 of the extended mode information of user mode information that is used to store current array location 1 track 11 and current array location 1; The state of first status field 112 comprise use with do not use two states, the state of second status field 122 comprise track 11 for empty, track 11 is full and array location 1 has been expanded three kinds of states.
As shown in Figure 8, first status field 112 adopts Inuse to represent user mode in the present embodiment, and Unused representes unused state.There is two states in first pointer field 111: have internal memory pointer and NULL.During track 11 initialization (INIT), first pointer field 111 is NULL, and first status field 112 is Unused; When there is Memory Allocation record (OCCUPIED) in track 11, be the internal memory pointer in first pointer field 111, first status field 112 is Inuse; Track 11 when (FREE), still records the internal memory pointer that has discharged in first pointer field 111 after release, first status field 112 is Unused.As shown in Figure 9, in the present embodiment second status field 122 adopt EMPTY represent track 11 for empty, adopt FULL to represent that track is 11 full, adopt INUSE to represent that array location 1 expanded.During expansion slot 12 initialization (INIT), second pointer field 121 is NULL, and second status field 122 is EMPTY.If when all tracks 11 of current array location 1 had been expired (FULL), second pointer field 121 was NULL, second status field 122 is FULL.If behind the array location 1 (EXPAND) that 1 expansion of current array location makes new advances, then second pointer field 121 is the internal memory pointer of the next array location 1 that expands, and second status field 122 is INUSE.
In the present embodiment, track 11 all has identical data structure with expansion slot 12.The structure type of track 11 defines as follows:
Struct?plog{
void*P
int?status
}
The structure type of expansion slot 12 defines as follows:
Struct?elog{
void*P
int?status
}
Wherein P is the pointer type variable, and status is the integer type variable, and P is used to write down the pointer value of first pointer field 111 or second pointer field 121, and status is used to write down the status information of first status field 112 or second status field 122.In the present embodiment, for first status field 112,0 expression Unused, 1 expression Inuse; For second status field 122,0 expression EMPTY, 1 expression FULL, 2 expression INUSE.
The array location 1 of present embodiment is made up of S track 11 and an expansion slot 12; Therefore the length of an array location 1 is S+1; S can be according to the decision of the average number of kernel module request storage allocation, and these data can be confirmed through the average internal memory application number that the operating system of actual measurement operation is added up kernel module.As with array location 1 of ploghead array representation, then the 1st~S storage space is that track 11, a S+1 storage space is an expansion slot 12.Shown in figure 10, when carrying out initialization, the memory headroom that at first distributes S+1 length is as the record body; Using a circulation that all tracks 11 and the expansion slot 12 of array location 1 are carried out initialization then, is NULL with first pointer field, 111 assignment, is Unused with first status field, 112 assignment; With second pointer field, 121 assignment is NULL; With second status field, 122 assignment is EMPTY, calls the kernel module inlet at last, begins kernel module is carried out initialization.
Present embodiment is in step 2) in when adding the Memory Allocation record, second status field 122 of at first reading the expansion slot 12 of first array location 1; Carry out judgment processing to second status field 122 then; If the track 11 that current array location 1 is still free; Then the Memory Allocation record is write empty track 11; If there is not empty track 11 after the array location 1 write memory assignment record again, then second status field 122 with expansion slot 12 is labeled as full; If the track 11 of current array location 1 is full; Then set up new array location 1; Second status field 122 of expansion slot 12 in the current array location 1 is related with new array location 1 foundation, then Memory Allocation is write down first the empty track 11 that writes new array location 1; If the expansion slot 12 of current array location 1 has been expanded the array location 1 that makes new advances, then with next array location 1 as current array location 1, return above-mentioned second status field 122 that is directed against and carry out judgment processing.In the operating system, memory allocation function have usually void*malloc (int size ...) form, the memory size of size wherein for need distributing; Void* is the memory address that system returns distribution.Shown in figure 11, ploghead represents an array location 1, and ploglist is the array variable that is used to handle, and the detailed step of present embodiment when adding the Memory Allocation record is following:
(1), giving ploglist, its effect with current ploghead assignment be with the current array location 1 of array variable ploglist sensing.
(2), judge the state of ploglist [S]:
If there is null record groove 11 among the ploglist; Obtain this track 11 and memory address is recorded in this null record groove 11; Simultaneously dead slot being labeled as Inuse promptly uses; If find it is last dead slot in the array, the status field of ploglist [S] is changed to FULL, all tracks 11 of expression ploglist are full.
If the track of ploglist 11 is full; And the array location 1 that makes new advances of expansion, the state of ploglist [S] is changed to Inuse, show and expand; Expand array location 1: at first distribute a new array location 1, array is recorded in the pointer field of ploghead [S].As null record groove 11, memory address records in this null record groove 11, and null record groove 11 is labeled as Inuse with first of new array location 1.
If ploglist has expanded the array that makes new advances, then ploglist is pointed to the ploghead of array location 1 correspondence of expansion, redirect execution in step again (2).
Present embodiment in step 3) when carrying out internal memory and discharge; At first search and wait to discharge content associated Memory Allocation record at all array locations 1 of record array; Carry out judgment processing according to first status field 112 that finds Memory Allocation record corresponding record groove 11 then; If first status field 112 is user mode, then stops inquiry and wait to discharge content associated Memory Allocation record; If first status field 112 is a unused state; Then continue to search and wait to discharge content associated Memory Allocation record; If find then continue to return above-mentioned first status field 112 that is directed against and carry out judgment processing, otherwise stop inquiry and wait to discharge content associated Memory Allocation record.Shown in figure 12, ploghead represents an array location 1, and ploglist is the array variable that is used to handle, and Q is an internal memory to be discharged, and present embodiment is following at the detailed step of carrying out before internal memory discharges:
1. give ploglist with the ploghead assignment;
2. judge Q whether with ploglist in the value coupling of first pointer field 111 of element, then first status field 112 is judged after finding first pointer field 111 of coupling:
If the first corresponding status field 112 is Inuse, expression discharges storage allocation, changes execution in step over to 3.;
If the first corresponding status field 112 is Unused, change execution in step over to 4.;
If do not find the pointer of coupling, represent that this internal memory was not assigned with in the past, wrong releasing operation has taken place, change execution in step over to 5..
3. the value with first pointer field, 111 corresponding first status fields 112 is changed to Unused; The internal memory of call operation system discharges logic and internal memory is discharged the memory management pond that is recycled to operating system; This operation guarantees to be gone on record by the correct releasing memory operation of module, changes execution in step at last over to 6..
4. continue to search, up to the Q that finds coupling, and corresponding Status is the record item of Inuse, and this moment is the Unused that is changed to of the corresponding Status of Q, and calls follow-up internal memory and discharges logic and internal memory is discharged the memory management pond that is recycled to operating system; If do not find, show repeatedly to discharge identical pointer, wrong release has taken place, can directly return after reporting an error and never call follow-up release logic, change execution in step at last over to 6..
5. directly return after reporting an error, never call follow-up release logic, change execution in step at last over to 6..
6. return the export function of carrying out kernel module.
In the present embodiment; Deletion Memory Allocation record is meant that with this Memory Allocation record mark be unused state in the step 3); When searching the Memory Allocation record; If find Memory Allocation record and this Memory Allocation record to be marked as unused state, then the warning message that internal memory discharges takes place repeatedly in output; In the step 4), if still leave the Memory Allocation record in the sweep record array time record array, then the warning message that internal memory is revealed takes place in output.
The sweep record array is first status field that is not eliminated to Inuse through searching in the step 4) of present embodiment.If there is first status field of Inuse, show that then the internal memory leakage exists, the free function internal memory that it is related according to Memory Allocation record calling system discharges one by one then, and final the removing write down array.
Below only be preferred implementation of the present invention, protection scope of the present invention also not only is confined to the foregoing description, and all technical schemes that belongs under the thinking of the present invention all belong to protection scope of the present invention.Should be pointed out that for those skilled in the art some improvement and retouching not breaking away under the principle of the invention prerequisite should be regarded as protection scope of the present invention.

Claims (5)

1. kernel module EMS memory management process that prevents that internal memory from revealing and internal memory repeatedly discharges is characterized in that implementation step is following:
1) sets up the record array that is used to write down this kernel module Memory Allocation record;
2) when kernel module Request System storage allocation, in said record array, add the Memory Allocation record that is associated with storage allocation;
3) when kernel module Request System releasing memory, in said record array, search and the Memory Allocation record of treating that releasing memory is associated, carry out internal memory release and delete this Memory Allocation record if the related Memory Allocation of existence writes down;
4) when kernel module withdraws from, the sweep record array if still leave the Memory Allocation record in the record array, then discharges according to the Memory Allocation record internal memory that it is related one by one, and the final record array of removing;
Said record array comprises at least one extendible array location (1); Said array location (1) is used for the track (11) of stored memory assignment record and expansion slot (12) that one is used to expand array location (1) is formed by a plurality of; Only comprise an array location (1) in the initial record array of setting up in the said step 1); Said step 2) when the lazy weight of the track (11) of an array location (1) during with the stored memory assignment record, the array location (1) that makes new advances through expansion slot (12) expansion comes the stored memory assignment record in.
2. the kernel module EMS memory management process that prevents that internal memory from revealing and internal memory repeatedly discharges according to claim 1; It is characterized in that: said track (11) by first pointer field (111) that is used for the stored memory positional information and first status field (112) that is used to store current record groove (11) user mode information form; Said expansion slot (12) is made up of second status field (122) of extended mode information that is used for storing second pointer field (121) of next array location (1) positional information and is used to store user mode information and the current array location (1) of current array location (1) track (11); The state of said first status field (112) comprise use with do not use two states, the state of said second status field (122) comprise track (11) for empty, track (11) is full and array location (1) has been expanded three kinds of states.
3. the kernel module EMS memory management process that prevents that internal memory from revealing and internal memory repeatedly discharges according to claim 2; It is characterized in that: when adding the Memory Allocation record said step 2), second status field (122) of at first reading the expansion slot (12) of first array location (1); Carry out judgment processing to second status field (122) then; If the track (11) that current array location (1) is still free; Then the Memory Allocation record is write empty track (11); If there is not empty track (11) after array location (1) the write memory assignment record again, then second status field (122) with expansion slot (12) is labeled as full; If the track (11) of current array location (1) is full; Then set up new array location (1); Second status field (122) of expansion slot (12) in the current array location (1) is related with new array location (1) foundation, then Memory Allocation is write down first the empty track (11) that writes new array location (1); If the expansion slot (12) of current array location (1) has been expanded the array location (1) that makes new advances, then with next array location (1) as current array location (1), return above-mentioned second status field (122) that is directed against and carry out judgment processing.
4. the kernel module EMS memory management process that prevents that internal memory from revealing and internal memory repeatedly discharges according to claim 2; It is characterized in that: in the said step 3) when carrying out internal memory and discharge; At first search and wait to discharge content associated Memory Allocation record at all array locations (1) of record array; Carry out judgment processing according to first status field (112) that finds Memory Allocation record corresponding record groove (11) then; If first status field (112) are user mode, then stop inquiry and wait to discharge content associated Memory Allocation record; If first status field (112) are unused state; Then continue to search and wait to discharge content associated Memory Allocation record; If find then continue to return above-mentioned first status field (112) that is directed against and carry out judgment processing, otherwise stop inquiry and wait to discharge content associated Memory Allocation record.
5. according to claim 2 or the 3 or 4 described kernel module EMS memory management process that prevent that internal memory from revealing and internal memory repeatedly discharges; It is characterized in that: deletion Memory Allocation record is meant that with this Memory Allocation record mark be unused state in the said step 3); Said searching Memory Allocation when record; If find Memory Allocation record and this Memory Allocation record to be marked as unused state, then the warning message that internal memory discharges takes place repeatedly in output; The sweep record array of said step 4) is first status field of user mode of being that is not eliminated through searching; If there is first status field of user mode; Show that then the internal memory leakage exists; The free function internal memory that it is related according to Memory Allocation record calling system discharges one by one then, and the warning message of internal memory leakage takes place for final removing record array and output.
CN2011100478005A 2011-02-28 2011-02-28 Kernel-module memory management method for preventing memory leaks and multiple memory releases Active CN102103541B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN2011100478005A CN102103541B (en) 2011-02-28 2011-02-28 Kernel-module memory management method for preventing memory leaks and multiple memory releases

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN2011100478005A CN102103541B (en) 2011-02-28 2011-02-28 Kernel-module memory management method for preventing memory leaks and multiple memory releases

Publications (2)

Publication Number Publication Date
CN102103541A CN102103541A (en) 2011-06-22
CN102103541B true CN102103541B (en) 2012-11-14

Family

ID=44156329

Family Applications (1)

Application Number Title Priority Date Filing Date
CN2011100478005A Active CN102103541B (en) 2011-02-28 2011-02-28 Kernel-module memory management method for preventing memory leaks and multiple memory releases

Country Status (1)

Country Link
CN (1) CN102103541B (en)

Families Citing this family (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102521148A (en) * 2011-11-18 2012-06-27 深圳中兴网信科技有限公司 Memory-based anti-overflow method of log information
CN102685590B (en) * 2012-05-14 2014-12-10 深圳市九洲电器有限公司 Method and device for managing set top box memory
CN102866947A (en) * 2012-08-29 2013-01-09 深圳市共进电子股份有限公司 Method for detecting internal memory leakage of Linux kernel
CN103488577A (en) * 2013-09-22 2014-01-01 北京航空航天大学 Method and device of memory allocation and batch recovery for user applications based on use numbering
CN104536773B (en) * 2015-02-03 2017-11-21 积成电子股份有限公司 Embedded software dynamic memory recovery method based on internal memory scanning
CN105893146B (en) * 2016-03-28 2020-01-10 北京小米移动软件有限公司 Memory processing method and device
EP3504628B1 (en) 2016-09-28 2020-09-09 Huawei Technologies Co., Ltd. Memory management method and device
CN107220182B (en) * 2017-06-20 2019-07-26 中国电子科技集团公司第五十四研究所 A kind of memory repetition release error-detecting method
CN109508235B (en) * 2018-09-28 2020-12-15 深圳市紫光同创电子有限公司 Memory pool management method and device and computer readable storage medium
CN109542778A (en) * 2018-11-12 2019-03-29 中国银联股份有限公司 A kind of method and device of resource leak detection

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1427342A (en) * 2001-12-21 2003-07-02 上海贝尔有限公司 Internal storage management system and its distribution method
CN1936859A (en) * 2005-09-30 2007-03-28 康佳集团股份有限公司 Internal memory monitoring method
CN101859279A (en) * 2010-05-21 2010-10-13 北京星网锐捷网络技术有限公司 Memory allocation and release method and device

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6782462B2 (en) * 2002-02-25 2004-08-24 International Business Machines Corporation System and method for tracking memory leaks
JP2005196343A (en) * 2004-01-05 2005-07-21 Mitsubishi Electric Corp Memory management device, memory management method and program

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1427342A (en) * 2001-12-21 2003-07-02 上海贝尔有限公司 Internal storage management system and its distribution method
CN1936859A (en) * 2005-09-30 2007-03-28 康佳集团股份有限公司 Internal memory monitoring method
CN101859279A (en) * 2010-05-21 2010-10-13 北京星网锐捷网络技术有限公司 Memory allocation and release method and device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
JP特開2005-196343A 2005.07.21

Also Published As

Publication number Publication date
CN102103541A (en) 2011-06-22

Similar Documents

Publication Publication Date Title
CN102103541B (en) Kernel-module memory management method for preventing memory leaks and multiple memory releases
CN101458613B (en) Method for implementing mixed hierarchical array, the hierarchical array and storage system
CN103577121B (en) A kind of highly reliable linear file access method based on Nand Flash
CN1316362C (en) Equipment and method of relocating shared computer data in multiline procedure computer
CN102262559B (en) Resource sharing method and system
CN100517240C (en) Allocation method for internal memory pool in embedded type operation system
CN107544756A (en) Method is locally stored in Key Value log types based on SCM
CN101221536A (en) Internal memory managing method and device of embedded system
CN1996258A (en) Method for implementing dynamic memory pool
CN107015763A (en) Mix SSD management methods and device in storage system
CN102841851A (en) Flash memory management method and flash memory device
CN107357680A (en) Data processing equipment and the method for data processing
CN101576830A (en) Deadlock detection method and device of database transaction lock mechanism
CN107256196A (en) The caching system and method for support zero-copy based on flash array
CN102063338A (en) Method and device for requesting exclusive resource
CN101110043A (en) Resource management method of multiple nucleus system and its controlling nucleus
CN107783908A (en) A kind of detection method based on linux kernel RAM leakage
CN101271428A (en) Apparatus and method for object data storage management
CN101770412A (en) Continuous data caching system and data caching method thereof
CN101968772A (en) Method for implementing efficient memory pool of embedded system
CN107817945A (en) A kind of method for reading data and system for mixing internal storage structure
CN103092765B (en) Solid-state memory system, device and method for writing data
CN109815005A (en) A kind of method, apparatus and storage system of managing internal memory
CN102609313B (en) Multi-core system resource delay recycle lock realizing method and multi-core system resource delay recycle lock realizing system
CN109445943A (en) The EMS memory management process of I/O stack, system and relevant apparatus in kernel state system

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant