Memory management method and device

By creating and managing dynamic arrays in VXLAN devices, dynamically adjusting memory according to user requests and usage, memory waste is solved and memory utilization is improved.

CN114610448BActive Publication Date: 2024-11-12HANGZHOU DPTECH TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210289364.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-22
Publication Date
2024-11-12
Estimated Expiration
2042-03-22

AI Technical Summary

Technical Problem

In the prior art, the memory management method of VXLAN devices has the problem of waste of static memory and unused space in dynamic arrays for a long time, especially when the VXLAN creation operation is not used for a long time.

Method used

By creating and initializing dynamic arrays in memory, creating and managing extended virtual LAN elements according to user requests, obtaining the array length and number of elements regularly, and dynamically adjusting the memory space based on this relationship to avoid unnecessary memory waste.

Benefits of technology

Dynamic recovery of the memory of electronic devices using extended virtual LAN technology is realized, memory utilization is improved, and memory waste is avoided when there is no use for a long time.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114610448B_ABST
    Figure CN114610448B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a memory management method, device, electronic device and computer-readable medium for extending a virtual local area network. The method comprises: creating and initializing a dynamic array in a memory; creating an extended virtual local area network element according to a user request and adding the extended virtual local area network element to the dynamic array; periodically obtaining the length of the dynamic array and the number of extended virtual local area network elements in the dynamic array; managing the dynamic array in the memory based on the relationship between the length of the dynamic array and the number of extended virtual local area network elements in the dynamic array. The memory management method, device, electronic device and computer-readable medium for extending a virtual local area network involved in the present application can dynamically recycle the memory in an electronic device using extended virtual local area network technology to improve memory utilization.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer information processing, and in particular, to a memory management method, device, electronic device and computer-readable medium for extending a virtual local area network. Background Art

[0002] In recent years, the development of cloud computing, virtualization and other related technologies and the introduction of software-defined networks have placed increasingly higher requirements on the quality and scope of Layer 2 LANs. Traditional VLAN technology can no longer meet the requirements.

[0003] To solve the virtual machine communication problem in large-scale networking, VMWare and other companies have proposed a hardware overlay technology, namely extended virtual local area network VXLAN. VXLAN is a tunnel encapsulation technology that encapsulates layer 2 messages in UDP headers. The encapsulated messages can be transparently transmitted in the IP core network and provide a maximum of 16M user isolation capability through virtual network identifiers.

[0004] Specifically at the software level, for each virtual network identifier, the program must maintain some information related to it, such as the forwarding domain ID and tunnel ID, so the program needs to manage a maximum of 16M groups of information. In order to manage this information, it is necessary to allocate memory of the corresponding size. There are generally two ways to manage memory.

[0005] One is static memory management. That is, the memory required to store all VXLAN-related information is applied for as soon as the program is started. However, most VXLANs have not been created at this time, so a large amount of memory space is not effectively used, which is a waste.

[0006] The other is dynamic memory management. That is, the size of the memory space for storing VXLAN-related information is not fixed but can be adjusted dynamically. This can minimize waste and save memory space.

[0007] The above information disclosed in the Background section is only for enhancement of understanding of the background of the present application and therefore it may contain information that does not constitute the prior art that is already known to a person of ordinary skill in the art. Summary of the invention

[0008] In view of this, the present application provides a memory management method, device, electronic device and computer-readable medium for extending a virtual local area network, which can dynamically recycle memory in an electronic device using extended virtual local area network technology to improve memory utilization.

[0009] Other features and advantages of the present application will become apparent from the following detailed description, or may be learned in part by the practice of the present application.

[0010] According to one aspect of the present application, a memory management method for extending a virtual local area network is proposed, the method comprising: creating and initializing a dynamic array in a memory; creating an extended virtual local area network element according to a user request and adding the extended virtual local area network element to the dynamic array; periodically obtaining the length of the dynamic array and the number of extended virtual local area network elements in the dynamic array; and managing the dynamic array in the memory based on the relationship between the length of the dynamic array and the number of extended virtual local area network elements in the dynamic array.

[0011] In an exemplary embodiment of the present application, creating and initializing a dynamic array in a memory includes: creating a dynamic array of a preset length in the memory; and initializing the dynamic array.

[0012] In an exemplary embodiment of the present application, initializing the dynamic array includes: creating a global variable; initializing based on an init_darray function; and setting a spin lock for the dynamic array.

[0013] In an exemplary embodiment of the present application, an extended virtual LAN element is created according to a user request and the extended virtual LAN element is added to a dynamic array, including: calling the insert_darray function according to the user request to create the extended virtual LAN element; when the number of elements in the dynamic array is equal to the length of the dynamic array, recreating a dynamic array and transferring the data in the current dynamic array and the extended virtual LAN element.

[0014] In an exemplary embodiment of the present application, a dynamic array is recreated and the data in the current dynamic array and the extended virtual LAN element are transferred, including: applying for heap space based on the length of the current dynamic array; creating a new dynamic array based on the heap space; storing the data in the current dynamic array into the new dynamic array; and inserting the extended virtual LAN element into the end of the new dynamic array.

[0015] In an exemplary embodiment of the present application, recreating a dynamic array and transferring the data in the current dynamic array and the extended virtual LAN element also includes: locking and unlocking the data in the dynamic array based on the spin lock in the struct darray function.

[0016] In an exemplary embodiment of the present application, periodically obtaining the length of the dynamic array and the number of extended virtual LAN elements in the dynamic array includes: creating and starting a timer thread; and periodically obtaining the length of the dynamic array and the number of extended virtual LAN elements in the dynamic array based on the timer thread.

[0017] In an exemplary embodiment of the present application, the dynamic array in the memory is managed based on the relationship between the length of the dynamic array and the number of extended virtual LAN elements in the dynamic array, including: when the length of the dynamic array is greater than the number of extended virtual LAN elements in the dynamic array, recreating a dynamic array and transferring the data in the current dynamic array.

[0018] In an exemplary embodiment of the present application, a dynamic array is recreated and data in the current dynamic array is transferred, including: applying for heap space based on the number of extended virtual LAN elements in the dynamic array; creating a new dynamic array based on the heap space; and storing the data in the current dynamic array in the new dynamic array.

[0019] According to one aspect of the present application, a memory management device for extending a virtual local area network is proposed, the device comprising: a creation module, used to create and initialize a dynamic array in a memory; an adding module, used to create an extended virtual local area network element according to a user request and add the extended virtual local area network element to the dynamic array; a timing module, used to periodically obtain the length of the dynamic array and the number of extended virtual local area network elements in the dynamic array; and a management module, used to manage the dynamic array in the memory based on the relationship between the length of the dynamic array and the number of extended virtual local area network elements in the dynamic array.

[0020] According to one aspect of the present application, an electronic device is proposed, which includes: one or more processors; a storage device for storing one or more programs; when the one or more programs are executed by the one or more processors, the one or more processors implement the method as described above.

[0021] According to one aspect of the present application, a computer-readable medium is provided, on which a computer program is stored. When the program is executed by a processor, the method described above is implemented.

[0022] According to the memory management method, device, electronic device and computer-readable medium for extending virtual local area network of the present application, by creating and initializing a dynamic array in the memory; creating an extended virtual local area network element according to a user request and adding the extended virtual local area network element to the dynamic array; periodically obtaining the length of the dynamic array and the number of extended virtual local area network elements in the dynamic array; and managing the dynamic array in the memory based on the relationship between the length of the dynamic array and the number of extended virtual local area network elements in the dynamic array, the memory in the electronic device using the extended virtual local area network technology can be dynamically recycled, thereby improving the memory utilization rate.

[0023] It should be understood that the foregoing general description and the following detailed description are exemplary only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] The above and other objects, features and advantages of the present application will become more apparent by describing in detail the exemplary embodiments thereof with reference to the accompanying drawings. The accompanying drawings described below are only some embodiments of the present application, and it is clear to a person skilled in the art that other accompanying drawings can be obtained from these accompanying drawings without creative effort.

[0025] Figure 1 The present invention is a system block diagram showing a memory management method and device for extending a virtual local area network according to an exemplary embodiment.

[0026] Figure 2 The present invention is a flowchart of a memory management method for extending a virtual local area network according to an exemplary embodiment.

[0027] Figure 3 The present invention is a flowchart of a memory management method for extending a virtual local area network according to another exemplary embodiment.

[0028] Figure 4 The present invention is a flowchart of a memory management method for extending a virtual local area network according to another exemplary embodiment.

[0029] Figure 5 The invention is a block diagram showing a memory management device for extending a virtual local area network according to an exemplary embodiment.

[0030] Figure 6 It is a block diagram of an electronic device according to an exemplary embodiment.

[0031] Figure 7 It is a block diagram of a computer-readable medium according to an exemplary embodiment. DETAILED DESCRIPTION

[0032] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in many forms and should not be construed as limited to the embodiments set forth herein; rather, these embodiments are provided so that this application will be comprehensive and complete and will fully convey the concepts of the example embodiments to those skilled in the art. The same reference numerals in the figures represent the same or similar parts, and thus their repeated description will be omitted.

[0033] In addition, described feature, structure or characteristic can be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present application. However, those skilled in the art will appreciate that the technical scheme of the present application can be put into practice without one or more of the specific details, or other methods, components, devices, steps, etc. can be adopted. In other cases, known methods, devices, realizations or operations are not shown or described in detail to avoid blurring the various aspects of the application.

[0034] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities may be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.

[0035] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps can be decomposed, and some operations / steps can be combined or partially combined, so the actual execution order may change according to actual conditions.

[0036] It should be understood that although the terms first, second, third, etc. may be used herein to describe various components, these components should not be limited by these terms. These terms are used to distinguish one component from another component. Therefore, the first component discussed below can be referred to as the second component without departing from the teachings of the concepts of the present application. As used herein, the term "and / or" includes any one of the associated listed items and all combinations of one or more.

[0037] Those skilled in the art will appreciate that the drawings are merely schematic diagrams of example embodiments, and the modules or processes in the drawings are not necessarily necessary for implementing the present application, and therefore cannot be used to limit the scope of protection of the present application.

[0038] The technical abbreviations involved in this application are explained as follows:

[0039] Tunneling: It is a type of network protocol. It is a data packet encapsulation technology that encapsulates the original IP packet in the data payload of another data packet for transmission.

[0040] Overlay: refers to a virtualization technology model superimposed on a network architecture. Its general framework is to enable applications to be carried on the network without making large-scale modifications to the underlying network.

[0041] The inventor of the present application discovered that in the prior art, methods for performing memory management on VXLAN devices include two methods: dynamic memory and static memory.

[0042] Among them, in the static memory management mode, the memory required to store all VXLAN related information is applied for as soon as the program is started. At this time, most VXLANs have not been created, so a large amount of memory space is not effectively used, which is a waste.

[0043] Among them, in the dynamic array method, the array has a default initial length. Each time a VXLAN is created, the corresponding information is inserted at the end of the array. If the amount of information stored in the array is greater than or equal to the length of the array, a new array is applied for, and the length of the new array is twice that of the original array. Then the data of the original array is copied to the new array, and then the memory space of the original array is released. In this technical solution, there is always some surplus in the array, that is, there is always some memory space that is not used. In the worst case, half of the space is not used. The larger the array length (that is, the more VXLANs are created), the more unused memory there is.

[0044] The inventors of the present application have found that for most users, the operation of creating a VXLAN occurs in a relatively concentrated period, and there may be no VXLAN creation operation for a long time afterwards, so the unused space in the dynamic array may not be utilized for a long time.

[0045] In order to solve the problems in the prior art, the memory management method and device for extending a virtual local area network of the present application proposes a dynamic memory management method with a recycling mechanism. Compared with the prior art solution, the method of the present application avoids the disadvantage that part of the memory cannot be used for a long time.

[0046] The following is a detailed description with reference to specific embodiments.

[0047] Figure 1 The present invention is a system block diagram showing a memory management method, device, electronic device and computer-readable medium for extending a virtual local area network according to an exemplary embodiment.

[0048] like Figure 1 As shown, the system architecture 10 may include terminal devices 101, 102, 103, a network 104, and a service device 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the service device 105. The network 104 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0049] Users can use terminal devices 101, 102, 103 to interact with service device 105 through network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc.

[0050] The terminal devices 101 , 102 , and 103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers.

[0051] An extended virtual local area network VXLAN may be created on the service device 105 for use by the terminal devices 101 , 102 , and 103 .

[0052] The service device 105 may, for example, create and initialize a dynamic array in the memory; the service device 105 may, for example, create an extended virtual LAN element according to the request of the terminal devices 101, 102, and 103 and add the extended virtual LAN element to the dynamic array; the service device 105 may, for example, periodically obtain the length of the dynamic array and the number of extended virtual LAN elements in the dynamic array; the service device 105 may, for example, manage the dynamic array in the memory based on the relationship between the length of the dynamic array and the number of extended virtual LAN elements in the dynamic array.

[0053] The service device 105 may be a physical server, or may be composed of multiple servers. It should be noted that the memory management method for extending a virtual local area network provided in the embodiment of the present application may be executed by the service device 105. Accordingly, the memory management device for extending a virtual local area network may be provided in the service device 105. The request end for data transmission provided to the user is generally located in the terminal devices 101, 102, and 103.

[0054] Figure 2 The flowchart of a memory management method for extending a virtual local area network according to an exemplary embodiment is shown. The memory management method 20 for extending a virtual local area network at least includes steps S202 to S208.

[0055] like Figure 2 As shown, in S202, a dynamic array is created and initialized in the memory. For example, a dynamic array of a preset length is created in the memory; and the dynamic array is initialized.

[0056] In one embodiment, initializing the dynamic array includes: creating a global variable; initializing based on an init_darray function; and setting a spin lock for the dynamic array.

[0057] Define the timer structure as follows:

[0058]

[0059] Among them, start is the time when the timer starts timing, now is the current time, thread_id is the timer thread ID, and lock is a spin lock used to protect data.

[0060] Define the dynamic array structure as follows:

[0061]

[0062] Among them, size is the number of elements in the array, capacity is the maximum number of elements that the array can store, the default initial length is DEFAULT_CAPACITY (that is, 8), arr is a pointer to the address of the first element of the array, lock is a spin lock used to protect data, and vxlan_timer is a timer structure variable.

[0063] After the program is started, a darray_t global variable can be created and initialized by calling the init_darray() function:

[0064] More specifically, you can initialize spin locks, initialize timers, and create timer threads;

[0065] For example, reset_timer() may be established as a timer initialization and reset function.

[0066] In S204, an extended virtual LAN element is created according to a user request and the extended virtual LAN element is added to a dynamic array. The insert_darray function may be called according to a user request to create an extended virtual LAN element; when the number of elements in the dynamic array is equal to the length of the dynamic array, a new dynamic array is created and the data in the current dynamic array and the extended virtual LAN element are transferred.

[0067] In one embodiment, a dynamic array is recreated and the data in the current dynamic array and the extended virtual LAN element are transferred, including: applying for heap space based on the length of the current dynamic array; creating a new dynamic array based on the heap space; storing the data in the current dynamic array into the new dynamic array; and inserting the extended virtual LAN element into the end of the new dynamic array.

[0068] In one embodiment, the method further includes: locking and unlocking the data in the dynamic array based on the spin lock in the struct darray function.

[0069] When a user creates a VXLAN, the insert_darray function can be called.

[0070] If the number of elements in the array is equal to the length of the array, re-apply space from the heap area to create a new array whose length is twice that of the original array, and copy the data of the original array to the new array.

[0071] Then insert the newly created vxlan related data into the end of the new array and reset the timer, which is called resetting the timer.

[0072] When operating the data in the struct darray variable, the spin lock in the struct darray can be used to lock and unlock the data.

[0073] In S206, the length of the dynamic array and the number of extended virtual local area network elements in the dynamic array are obtained periodically. A timer thread may be created and started; and the length of the dynamic array and the number of extended virtual local area network elements in the dynamic array are obtained periodically based on the timer thread.

[0074] In S208, the dynamic array in the memory is managed based on the relationship between the length of the dynamic array and the number of extended virtual local area network elements in the dynamic array. For example, when the length of the dynamic array is greater than the number of extended virtual local area network elements in the dynamic array, a new dynamic array is created and data in the current dynamic array is transferred.

[0075] More specifically, a heap space may be applied for based on the number of extended virtual local area network elements in the dynamic array; a new dynamic array may be created based on the heap space; and data in the current dynamic array may be stored in the new dynamic array.

[0076] According to the memory management method for extending virtual local area network of the present application, by creating and initializing a dynamic array in the memory; creating an extended virtual local area network element according to a user request and adding the extended virtual local area network element to the dynamic array; periodically obtaining the length of the dynamic array and the number of extended virtual local area network elements in the dynamic array; and managing the dynamic array in the memory based on the relationship between the length of the dynamic array and the number of extended virtual local area network elements in the dynamic array, the memory in the electronic device using the extended virtual local area network technology can be dynamically recycled, thereby improving the memory utilization rate.

[0077] It should be clearly understood that the present application describes how to form and use specific examples, but the principles of the present application are not limited to any details of these examples. On the contrary, based on the teaching of the content disclosed in the present application, these principles can be applied to many other embodiments.

[0078] Figure 3 The present invention is a flowchart of a memory management method for extending a virtual local area network according to another exemplary embodiment. Figure 3 The process 30 shown is for Figure 2 The detailed description of S208 in the process shown is "when the length of the dynamic array is greater than the number of extended virtual LAN elements in the dynamic array, re-create a dynamic array and transfer the data in the current dynamic array."

[0079] like Figure 3 As shown, in S302, the length of the dynamic array is periodically compared to be greater than the number of extended virtual LAN elements in the dynamic array.

[0080] In S304, when the length is greater than the number, heap space is applied for based on the number of extended virtual local area network elements in the dynamic array.

[0081] In S306, a new dynamic array is created based on the heap space.

[0082] In S308, the data in the current dynamic array is stored in the new dynamic array.

[0083] In S310, the timer is reset.

[0084] If the timer expires, it means that no array insertion operation has been performed during the timer timing period (otherwise the timer will be reset), triggering the memory recycling mechanism.

[0085] If the array length is the default initial length, or the number of array elements is equal to the array length, reset the timer and do no other operations; otherwise, reapply for memory to ensure that there is no excess memory space, and then reset the timer.

[0086] In a specific embodiment, the timer time can be set to 1 hour, that is, if no element is added to the array within 1 hour, the memory recycling function is called.

[0087] More specifically, the definition of the timer expiration processing function realloc_darray() is as follows:

[0088]

[0089] Figure 4 The present invention is a flowchart of a memory management method for extending a virtual local area network according to another exemplary embodiment. Figure 4 The process 40 shown is for Figure 2 Detailed description of the process shown.

[0090] like Figure 4As shown, in S401, the program starts.

[0091] In S402 , a dynamic array is created and initialized.

[0092] In S403, the timer is initialized and a timer thread is created.

[0093] In S404, the timer is reset.

[0094] In S405 , the timer thread starts timing.

[0095] In S406, the timer expires.

[0096] In S407, the array length is a default size or the number of elements is equal to the length.

[0097] In S408, memory is reclaimed.

[0098] In S409, a VXLAN is created.

[0099] In S410, a dynamic array is added.

[0100] In S411, the timer is reset.

[0101] In the use scenario of VXLAN, VXLAN creation occurs in a relatively concentrated period. For dynamic arrays storing VXLAN-related data, if no new elements are added to the array (VXLAN creation) within a certain period, the array is re-applied and the original array data is copied to the new array. Ensure that the number of elements is the same as the length of the new array, there is no extra space, reclaim memory, and avoid waste.

[0102] The memory management method for extending a virtual local area network of the present application is mainly used to manage the memory space required by the VXLAN and has the following advantages:

[0103] 1. When no new VXLAN is created for a long time, reclaim excess memory space in time to avoid waste.

[0104] 2. Relatively easy to implement and highly reliable.

[0105] Those skilled in the art will appreciate that all or part of the steps for implementing the above embodiments are implemented as a computer program executed by a CPU. When the computer program is executed by the CPU, the above functions defined by the above method provided in the present application are executed. The program may be stored in a computer-readable storage medium, which may be a read-only memory, a disk, or an optical disk, etc.

[0106] In addition, it should be noted that the above figures are only schematic illustrations of the processes included in the method according to the exemplary embodiments of the present application, and are not intended to be limiting. It is easy to understand that the processes shown in the above figures do not indicate or limit the time sequence of these processes. In addition, it is also easy to understand that these processes can be performed synchronously or asynchronously, for example, in multiple modules.

[0107] The following is an embodiment of the device of the present application, which can be used to execute the embodiment of the method of the present application. For details not disclosed in the embodiment of the device of the present application, please refer to the embodiment of the method of the present application.

[0108] Figure 5 FIG. 1 is a block diagram of a memory management device for extending a virtual local area network according to an exemplary embodiment. Figure 5 As shown, the memory management device 50 for extending a virtual local area network includes: a creation module 502 , a joining module 504 , a timing module 506 , and a management module 508 .

[0109] The creation module 502 is used to create and initialize a dynamic array in the memory; the creation module 502 is also used to create a dynamic array of a preset length in the memory; and initialize the dynamic array.

[0110] The adding module 504 is used to create an extended virtual LAN element according to a user request and add the extended virtual LAN element to a dynamic array; the adding module 504 is also used to call the insert_darray function according to a user request to create an extended virtual LAN element; when the number of elements in the dynamic array is equal to the length of the dynamic array, a dynamic array is recreated and the data in the current dynamic array and the extended virtual LAN element are transferred.

[0111] The timing module 506 is used to periodically obtain the length of the dynamic array and the number of extended virtual LAN elements in the dynamic array; the timing module 506 is also used to create and start a timer thread; based on the timer thread, the length of the dynamic array and the number of extended virtual LAN elements in the dynamic array are periodically obtained.

[0112] The management module 508 is used to manage the dynamic array in the memory based on the relationship between the length of the dynamic array and the number of extended virtual local area network elements in the dynamic array. The management module 508 is also used to recreate a dynamic array and transfer data in the current dynamic array when the length of the dynamic array is greater than the number of extended virtual local area network elements in the dynamic array.

[0113] According to the memory management device for extending virtual local area network of the present application, by creating and initializing a dynamic array in the memory; creating an extended virtual local area network element according to a user request and adding the extended virtual local area network element to the dynamic array; periodically obtaining the length of the dynamic array and the number of extended virtual local area network elements in the dynamic array; and managing the dynamic array in the memory based on the relationship between the length of the dynamic array and the number of extended virtual local area network elements in the dynamic array, the memory in the electronic device using the extended virtual local area network technology can be dynamically recycled, thereby improving the memory utilization rate.

[0114] Figure 6 It is a block diagram of an electronic device according to an exemplary embodiment.

[0115] Refer to the following Figure 6 The electronic device 600 according to this embodiment of the present application is described. Figure 6 The electronic device 600 shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0116] like Figure 6 As shown, the electronic device 600 is in the form of a general computing device. The components of the electronic device 600 may include, but are not limited to: at least one processing unit 610, at least one storage unit 620, a bus 630 connecting different system components (including the storage unit 620 and the processing unit 610), a display unit 640, etc.

[0117] The storage unit stores a program code, which can be executed by the processing unit 610, so that the processing unit 610 performs the steps described in this specification according to various exemplary embodiments of the present application. For example, the processing unit 610 can perform the following steps: Figure 2 , Figure 3 , Figure 4 Follow the steps shown in .

[0118] The storage unit 620 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM) 6201 and / or a cache memory unit 6202 , and may further include a read-only memory unit (ROM) 6203 .

[0119] The storage unit 620 may also include a program / utility 6204 having a set (at least one) of program modules 6205, such program modules 6205 including but not limited to: an operating system, one or more application programs, other program modules and program data, each of which or some combination may include the implementation of a network environment.

[0120] Bus 630 may represent one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.

[0121] The electronic device 600 may also communicate with one or more external devices 600' (e.g., keyboards, pointing devices, Bluetooth devices, etc.) to enable a user to communicate with the electronic device 600, and / or any device (e.g., routers, modems, etc.) that the electronic device 600 can communicate with one or more other computing devices. Such communication may be performed via an input / output (I / O) interface 650. In addition, the electronic device 600 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) via a network adapter 660. The network adapter 660 may communicate with other modules of the electronic device 600 via a bus 630. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 600, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0122] In general, after the process is started, a darray_t global variable is created and the init_darray() function is called to initialize it:

[0123]

[0124]

[0125]

[0126] Here, realloc_darray() is a timer expiration processing function, that is, a dynamic array memory recovery function, such as the timer expiration processing mentioned above.

[0127] When the user creates a VXLAN, the insert_darray function is called. If the number of elements in the array is equal to the length of the array, space is re-applied from the heap area to create a new array whose length is twice that of the original array, and the data of the original array is copied to the new array. Then the newly created vxlan related data is inserted into the end of the new array, and the timer is reset. When operating the data in the struct darray variable, the spin lock in the struct darray is used for locking and unlocking operations. The insert_darray function is defined as follows:

[0128]

[0129]

[0130] Through the above description of the implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by combining software with necessary hardware. Figure 7 As shown, the technical solution according to the implementation mode of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes a number of instructions to enable a computing device (which can be a personal computer, a server, or a network device, etc.) to execute the above method according to the implementation mode of the present application.

[0131] The software product may be any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, a system, device or component of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination thereof. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof.

[0132] The computer readable storage medium may include a data signal propagated in a baseband or as part of a carrier wave, wherein a readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The readable storage medium may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by an instruction execution system, an apparatus, or a device or used in combination with it. The program code contained on the readable storage medium may be transmitted with any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the above.

[0133] Program code for performing the operations of the present application may be written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Java, C++, etc., and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., using an Internet service provider to connect through the Internet).

[0134] The computer-readable medium carries one or more programs. When the one or more programs are executed by a device, the computer-readable medium implements the following functions: creating and initializing a dynamic array in a memory; creating an extended virtual LAN element according to a user request and adding the extended virtual LAN element to the dynamic array; periodically obtaining the length of the dynamic array and the number of extended virtual LAN elements in the dynamic array; and managing the dynamic array in the memory based on the relationship between the length of the dynamic array and the number of extended virtual LAN elements in the dynamic array.

[0135] Those skilled in the art will appreciate that the above modules can be distributed in the device according to the description of the embodiment, or can be changed accordingly and only used in one or more devices different from the embodiment. The modules of the above embodiments can be combined into one module, or further divided into multiple sub-modules.

[0136] Through the description of the above embodiments, it is easy for those skilled in the art to understand that the example embodiments described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the embodiment of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a mobile terminal, or a network device, etc.) to execute the method according to the embodiment of the present application.

[0137] The exemplary embodiments of the present application are specifically shown and described above. It should be understood that the present application is not limited to the detailed structures, configurations or implementations described herein; on the contrary, the present application is intended to cover various modifications and equivalent configurations included in the spirit and scope of the appended claims.

Claims

1. A memory management method for extending a virtual local area network, characterized in that: include: Create and initialize a dynamic array in memory; Creating an extended virtual local area network element according to a user request and adding the extended virtual local area network element to the dynamic array; Regularly acquiring the length of the dynamic array and the number of extended virtual local area network elements in the dynamic array; The dynamic array in the memory is managed based on the relationship between the length of the dynamic array and the number of extended virtual LAN elements in the dynamic array, including: when the length of the dynamic array is greater than the number of extended virtual LAN elements in the dynamic array, applying for heap space based on the number of extended virtual LAN elements in the dynamic array and creating a new dynamic array based on the heap space, and storing data in the current dynamic array in the new dynamic array to ensure that the number of elements is the same as the length of the new array and there is no redundant space.

2. The method according to claim 1, characterized in that Create and initialize a dynamic array in memory, including: Create a dynamic array of preset length in memory; Initializes the dynamic array.

3. The method according to claim 2, characterized in that Initializing the dynamic array includes: Create global variables; Initialization based on init_darray function; A spin lock is set for the dynamic array.

4. The method according to claim 1, characterized in that Creating an extended virtual local area network element according to a user request and adding the extended virtual local area network element to a dynamic array includes: Call the insert_darray function to create an extended virtual LAN element based on the user's request; When the number of elements in the dynamic array is equal to the length of the dynamic array, a dynamic array is recreated and the data in the current dynamic array and the extended virtual local area network element are transferred.

5. The method according to claim 4, characterized in that Re-creating a dynamic array and transferring the data in the current dynamic array and the extended virtual local area network element, including: Apply for heap space based on the current length of the dynamic array; Creating a new dynamic array based on the heap space; Store the data in the current dynamic array into the new dynamic array; Insert the extended virtual local area network element into the end of the new dynamic array.

6. The method according to claim 5, characterized in that Re-creating a dynamic array and transferring the data in the current dynamic array and the extended virtual local area network element also includes: The data in the dynamic array is locked and unlocked based on the spin lock in the struct darray function.

7. The method according to claim 1, characterized in that The length of the dynamic array and the number of extended virtual local area network elements in the dynamic array are obtained periodically, including: Create and start the timer thread; The length of the dynamic array and the number of extended virtual local area network elements in the dynamic array are obtained based on the timer thread timing acquisition.

8. A memory management device for extending a virtual local area network, characterized in that: include: Create a module to create and initialize a dynamic array in memory; An adding module, used for creating an extended virtual local area network element according to a user request and adding the extended virtual local area network element to the dynamic array; A timing module, used for periodically acquiring the length of the dynamic array and the number of extended virtual local area network elements in the dynamic array; A management module is used to manage the dynamic array in the memory based on the relationship between the length of the dynamic array and the number of extended virtual local area network elements in the dynamic array, including: when the length of the dynamic array is greater than the number of extended virtual local area network elements in the dynamic array, applying for heap space based on the number of extended virtual local area network elements in the dynamic array and creating a new dynamic array based on the heap space, and storing data in the current dynamic array in the new dynamic array to ensure that the number of elements is the same as the length of the new array and there is no redundant space.