CN111597046B - Endoscope memory management method and endoscope - Google Patents

Endoscope memory management method and endoscope Download PDF

Info

Publication number
CN111597046B
CN111597046B CN202010412915.9A CN202010412915A CN111597046B CN 111597046 B CN111597046 B CN 111597046B CN 202010412915 A CN202010412915 A CN 202010412915A CN 111597046 B CN111597046 B CN 111597046B
Authority
CN
China
Prior art keywords
memory
mode
function
endoscope
window
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
CN202010412915.9A
Other languages
Chinese (zh)
Other versions
CN111597046A (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.)
Autel Intelligent Technology Corp Ltd
Original Assignee
Autel Intelligent Technology Corp Ltd
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 Autel Intelligent Technology Corp Ltd filed Critical Autel Intelligent Technology Corp Ltd
Priority to CN202010412915.9A priority Critical patent/CN111597046B/en
Publication of CN111597046A publication Critical patent/CN111597046A/en
Priority to PCT/CN2021/088777 priority patent/WO2021227803A1/en
Application granted granted Critical
Publication of CN111597046B publication Critical patent/CN111597046B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5016Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T1/00General purpose image data processing
    • G06T1/60Memory management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Endoscopes (AREA)
  • Instruments For Viewing The Inside Of Hollow Bodies (AREA)

Abstract

The embodiment of the invention relates to the technical field of diagnostic equipment, and discloses an endoscope memory management method and an endoscope. The endoscope memory management method comprises the following steps: in a current functional mode, acquiring a mode switching instruction, wherein the current functional mode is any one mode of a real-time video preview mode, a media management mode and a setting mode, and the real-time video preview mode, the media management mode and the setting mode are mutually decoupled so that at least part of memory resources occupied by the functional modes are not shared; switching the current functional mode to be a target functional mode pointed by the mode switching instruction; and releasing the memory resources occupied by the current functional mode. Through the mode, the embodiment of the invention improves the utilization rate of the memory resources.

Description

Endoscope memory management method and endoscope
Technical Field
The invention relates to the technical field of diagnostic equipment, in particular to an endoscope memory management method and an endoscope.
Background
The endoscope is a detection instrument integrating traditional optics, ergonomics, precision machinery, modern electronics, mathematics, software and the like, and is mainly used for checking the quality of automobile manufacture and maintenance, precision machining manufacture, petrochemical industry, military industry manufacture, small aperture in small equipment, the internal condition of small gaps, abrasion of mechanical gear parts, looseness and oil nozzle oil pump.
In the process of implementing the present invention, the inventors found that the following problems exist in the prior art: currently, the requirements for acquiring and processing images of an endoscope are increasing, for example, the endoscope is provided with a plurality of image acquisition devices, and further, a high-definition image acquisition device is required to be configured. And the functions of video and image processing are multiple, the memory requirement is large, and some functions require continuous memory, so that the shortage of memory resources is further caused, the failure of the implementation of the endoscope function is easily caused, and the user experience is reduced. Therefore, how to effectively utilize the memory resources in the endoscope is a problem to be solved by those skilled in the art.
Disclosure of Invention
The embodiment of the invention aims to provide an endoscope memory management method and an endoscope, which can improve the utilization rate of memory resources.
In order to solve the technical problems, the embodiment of the invention provides the following technical scheme:
in a first aspect, an embodiment of the present invention provides a method for managing memory of an endoscope, including:
in a current functional mode, acquiring a mode switching instruction, wherein the current functional mode is any one mode of a real-time video preview mode, a media management mode and a setting mode, and the real-time video preview mode, the media management mode and the setting mode are mutually decoupled so that at least part of memory resources occupied by the functional modes are not shared;
Switching the current functional mode to be a target functional mode pointed by the mode switching instruction;
and releasing the memory resources occupied by the current functional mode.
In some embodiments, the method further comprises:
acquiring a function selection instruction when executing a user interaction function in the current function mode;
searching a preset menu tree according to the function selection instruction to traverse a target window pointed by the function selection instruction step by step, wherein the preset menu tree comprises branch menus corresponding to each current function mode, and each branch menu comprises a father window and a plurality of child windows under the father window;
and displaying the target window.
In some embodiments, the child window under each of the parent windows is no more than three.
In some embodiments, the displaying the target window includes:
displaying the target window according to the corresponding relation between the user interaction function and the window;
the corresponding relation comprises a double buffer window corresponding to the video playback function, and a dialog box window or a common window corresponding to other user interaction functions except the video playback function.
In some embodiments, the method further comprises:
And destroying other pictures along with destroying the window except for the picture used by the target window and the picture used by the child window under the parent window in the parent window.
In some embodiments, the method further comprises:
and loading only the character strings corresponding to the language used by the user interaction function or the character strings corresponding to the current function mode.
In some embodiments, the method further comprises:
and cutting a word stock of the endoscope according to the user interaction function.
In some embodiments, the method further comprises:
scanning a plurality of memory fragments of the endoscope;
and compressing the memory fragments at fixed time.
In some embodiments, the method further comprises:
scanning a plurality of memory fragments of the endoscope;
and compressing the memory fragments when the functional mode is switched.
In some embodiments, the method further comprises:
determining a memory allocation strategy according to the function executed in the current function mode;
and according to the memory allocation strategy, when the function is executed, releasing the variable or object used by the function.
In a second aspect, embodiments of the present invention provide an endoscope comprising:
At least one processor; the method comprises the steps of,
a memory communicatively coupled to the at least one processor; wherein,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the endoscope memory management method as set forth in any one of the preceding claims.
In a third aspect, embodiments of the present invention also provide a non-transitory computer-readable storage medium storing computer-executable instructions for enabling an endoscope to perform the endoscope memory management method as set forth in any one of the above.
The embodiment of the invention has the beneficial effects that: compared with the prior art, the endoscope memory management method and the endoscope provided by the embodiment of the invention have the advantages that the functions supported by the endoscope are decoupled into the real-time video preview mode, the media management mode and the setting mode, so that at least part of memory resources occupied by each function mode are not shared, and when the current function mode is switched, the memory resources occupied by the current function mode are released. Therefore, the embodiment of the invention improves the utilization rate of the memory resources.
Drawings
One or more embodiments are illustrated by way of example and not limitation in the figures of the accompanying drawings, in which like references indicate similar elements, and in which the figures of the drawings are not to be taken in a limiting sense, unless otherwise indicated.
FIG. 1 is a block diagram of an endoscope memory management system according to an embodiment of the present invention;
FIG. 2 is a flow chart of one of the methods for endoscope memory management according to the present invention;
FIG. 3 is a flow chart of one of the methods for endoscope memory management according to the present invention;
FIG. 4 is a schematic diagram of a preset menu tree according to an embodiment of the present invention;
FIG. 5 is a flow chart of one of the methods for endoscope memory management according to the present invention;
FIG. 6 is a flow chart of one of the methods for endoscope memory management according to the present invention;
FIG. 7 is a flow chart of one of the methods for endoscope memory management according to the present invention;
FIG. 8 is a schematic diagram of an embodiment of an endoscope memory management device;
FIG. 9 is a schematic diagram of an endoscope memory management device according to an embodiment of the present invention;
fig. 10 is a schematic view of an endoscope according to an embodiment of the present invention.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the described embodiments are some embodiments of the present invention, but not all embodiments of the present invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
It should be noted that although functional block division is performed in a device diagram and a logic sequence is shown in a flowchart, in some cases, the steps shown or described may be performed in a different order than the block division in the device, or in the flowchart. In addition, the terms "first," "second," etc. are used for descriptive purposes only and are not to be construed as indicating or implying relative importance.
In addition, the technical features of the embodiments of the present invention described below may be combined with each other as long as they do not collide with each other.
An embodiment of the present invention provides an architecture diagram of an endoscope memory management system, as shown in fig. 1, which includes an endoscope 10 and a device to be inspected 20. The endoscope 10 may be used to inspect the manufacturing and maintenance procedures of the device 20 to be inspected. The equipment to be inspected 20 includes automobiles, home appliances, various types of pipes, medical equipment, aviation equipment, mechanical equipment, and the like. The embodiment of the present invention will be described by taking the endoscope 10 as an automotive endoscope as an example.
The car endoscope comprises a plurality of high-definition cameras, an illumination light source, a display screen, keys, a loudspeaker, a microphone, a battery, an indicator light, a charger and the like (not shown), and can be connected to the processor 101 shown in fig. 10. The MCU of a plurality of high-definition cameras and the automobile endoscope are communicated through USB, a compressed MJpeg format (a compressed image format) picture is transmitted, the MCU runs a Linux system, and detection data sent by a plurality of high-definition cameras are received through UVC (USB Video Class) and decompressed into image data in YUV format (an image data storage format) for Video preview, recording or image storage.
Wherein, the automobile endoscope comprises the following aspects in the maintenance process of the automobile: (1) lumen examination: checking surface cracks, peeling, wire drawing, scratches, pits, bulges, spots, corrosion and other defects; (2) status checking: when certain products (such as turbines, engines and the like) work, performing endoscopic detection according to items specified by technical requirements; (3) assembly inspection: after a certain or all assembly steps are completed, checking whether the assembly positions of all parts accord with the pattern or technical requirements, whether assembly defects exist or not, and the like; (4) redundant inspection: detecting surplus matters such as residual inner scraps, foreign matters and the like in the inner cavity of the product; (5) weld surface defect inspection: and checking welding problems such as surface cracks, incomplete welding, missing welding and the like of the welding line.
Taking a state inspection of an automobile endoscope as an example, when the automobile endoscope is used for engine cleaning inspection, before the engine is cleaned, observing carbon deposition conditions and the like in the engine by using the automobile endoscope, and acquiring a first image; after the engine is cleaned, observing carbon deposition conditions and the like in the engine by using an automobile endoscope again, and acquiring a second image; the first image and the second image are compared, and the engine cleaning effect can be intuitively observed. When the automobile endoscope is used for engine quality inspection, the automobile endoscope is adopted to inspect the inner cavity of the engine, and a third image is acquired; judging whether casting defects or burrs exist in the inner cavity of the engine or not by observing the third image; if casting defects or burrs exist in the inner cavity of the engine, the engine is sent to a maintenance area; and if the casting defect or burr does not exist in the inner cavity of the engine, determining that the quality of the engine is qualified.
In some application scenarios, the endoscope memory management system further comprises a terminal device 30. The terminal device 30 is in communication connection with the car endoscope, and the terminal device 30 is used for storing or processing detection data sent by the car endoscope. The terminal device 30 may include a portable mobile electronic device such as a smart phone, a computer, a palm computer, a tablet computer, a smart watch, a large-sized computing device such as a server, and other electronic apparatuses with data interaction functions.
As shown in fig. 2, an embodiment of the present invention provides an endoscope memory management method, and an endoscope memory management method S200 may be applied to the endoscope shown in fig. 1, where the endoscope memory management method S200 includes:
s21, under the current function mode, acquiring a mode switching instruction, wherein the current function mode is any one mode of a real-time video preview mode, a media management mode and a setting mode, and the real-time video preview mode, the media management mode and the setting mode are mutually decoupled so as to enable at least part of memory resources occupied by the function modes to be unshared.
In the embodiment of the application, the endoscope can divide the realized functions into a real-time video preview function, a media management function and a setting function according to the access or occupation requirements to the memory resources, so that the requirements to the memory resources among the functions are mutually distinguished, and the requirements to the memory resources in the functions have common characteristics. Specific requirements of the functions for memory resources can be seen from the following description.
Each function corresponds to a function mode, which is a real-time video preview mode, a media management mode and a setting mode. The endoscope can be switched among the three modes so as to respectively realize functions corresponding to the functional modes. Wherein, the switching of the functional mode can be triggered by the user operation; or the endoscope is triggered according to specific triggering conditions, and the embodiment of the application is not limited to the specific triggering conditions.
The realization of each function can be realized by a program module stored in a memory of the endoscope, namely, the MCU of the endoscope is realized by running an executable program in the memory; of course, it is also possible to implement the program modules in connection with the corresponding hardware.
Each function may include several sub-functions to refine the implementation of each function. For specific sub-functions included for each function, see the description below. Wherein the behavior of the endoscope implemented for realizing each function or sub-functions comprised by each function is understood as a service in each functional mode. The mutual decoupling of each functional mode refers to the mutual decoupling of services in each functional mode. Service mutual decoupling is understood to mean that the service between the functions has low or no correlation, and the service has independent access requirements or at least partial independent access requirements to the memory resources when the functions are implemented. The independent access requirement of the service on the memory resource when the service realizes the function means that the service in a certain function mode does not need to be associated with the service in other function modes, and the service in the function mode does not need to be accessed on the memory resource in other function modes. When the endoscope runs in a certain functional mode, the endoscope can allocate memory resources for the service in the functional mode, and when the endoscope is switched to another functional mode, the endoscope releases the memory resources in the previous functional mode and reallocates the memory resources for the service in the other functional mode. It is also understood that at least a portion of the memory resources occupied by each functional mode are not shared.
The memory resources occupied by each functional mode are the access or other operations of the service to the memory resources in the implementation function. After the functional mode is determined, the endoscope can allocate corresponding memory resources for the realization of the function according to the demand characteristics of the function corresponding to the functional mode for the memory resources, and the allocated memory resources can be understood as the memory resources occupied by the functional mode, so that the non-sharing of the memory resources in each functional mode is realized. In general, most of memory resources in each functional mode are independent and not shared with memory resources in other functional modes; there is a special case that there is an overlap in the demands for memory resources between the functions, and the memory resources of each function mode partially share the memory resources occupied by the overlap portion, so as to respectively implement the functions corresponding to each function mode. If after the endoscope determines the function mode, when corresponding memory resources are allocated for the implementation of the function, the implementation of the function is found to depend on the memory resources occupied by other function modes, and the memory resources occupied by other function modes are required to be accessed to call related memory resources, so that the function or the sub-function included in the function is realized in the function mode.
The real-time video preview function comprises image transmission, image decoding, image scaling, format conversion, image display and the like. When the endoscope is used for photographing or video recording, the real-time video preview function also comprises image or video compression, file storage and the like. For the live video preview function, all image processing related operations require continuous memory. The continuous physical memory of the real-time video preview function is mainly large-block continuous memory, and the continuous memory has a plurality of blocks, so that the requirement of the continuous physical memory is constant. The non-contiguous physical memory of the live video preview function is less demanding but the demand is constant.
The media management function needs to open up a window for UI (User Interface) interaction, and the UI includes picture presentation and video playback. Wherein the picture presentation is based primarily on the form of thumbnail images, the thumbnail image operation involves image decoding and image scaling. Video playback operations require video decoding and image output. For media management functions, continuous memory is required for image and video related operations. The continuous physical memory of the media management function is mainly small-block continuous memory, but the continuous memory has a plurality of blocks, and the requirement of the continuous physical memory is constant. The discontinuous physical memory of the media management function is in more demand, and the demand quantity is related to the number of files.
The setting function is used to set system applications and configuration parameters, such as interfaces that can be used to set a live video preview function and a media management function, for example, image scaling, and the setting function can be used to set a triggering operation, a scaling operation, a zoom-in or zoom-out multiple, a display mode, a hover mode, an end operation, and the like of image scaling. For continuous physical memory with set functions, a large continuous physical memory is used for establishing windows, a small continuous physical memory is used for UI pictures, and the continuous physical memory is related to the number of windows. The discontinuous physical memory of the setting function is more in demand, and the demand quantity is related to the number of windows.
S22, switching the current functional mode to be the target functional mode pointed by the mode switching instruction.
S23, releasing the memory resources occupied by the current functional mode.
Endoscopes are generally developed based on embedded systems, and since at least part of memory resources occupied by each functional mode are not shared, the memory resources can be considered only according to the memory requirement of the current functional mode when the embedded system allocates memory. When the current function mode is switched to be the target function mode pointed by the mode switching instruction, the memory resources occupied by the current function mode are released, and the memory space is vacated for the target function mode, so that the situations of insufficient memory resources, failed memory resource application, incapability of normal operation of service functions and the like are avoided.
For example, in real-time video preview mode, the endoscope system occupies a large amount of continuous physical memory for video capture, real-time image processing, and display. When the real-time video preview mode is switched to the media management mode, the memory access requirement is mainly UI and media file content display, the real-time video is not required to be displayed to a user any more, the real-time video acquisition unit and the image processing unit can be closed, and a large amount of continuous physical memory is released. When the media management mode is switched to the real-time video preview mode again, the memory resources occupied by the media management mode are released, the memory resources are redistributed for the real-time video preview mode, and a plurality of high-definition cameras of the endoscope are opened.
As shown in fig. 3, in some embodiments, the method further includes an endoscope memory management method S300, including:
s31, acquiring a function selection instruction when executing a user interaction function in the current function mode.
S32, searching a preset menu tree according to the function selection instruction so as to traverse the target window pointed by the function selection instruction step by step, wherein the preset menu tree comprises branch menus corresponding to each current function mode, and each branch menu comprises a parent window and a plurality of child windows under the parent window.
Wherein the child window under each parent window is not more than three.
Fig. 4 is a schematic diagram of a preset menu tree according to an embodiment of the present invention. The preset menu tree is designed according to the interrelation between service functions and operation flow. The invention takes a 3-layer preset menu tree as an example, and comprises a first-layer menu node L11, second-layer menu nodes L21, L22 and L23, and third-layer menu nodes L31, L32, L33, L34, L35 and L36.
Each menu node corresponds to a window, the window corresponding to the menu node L11 is a parent window, and the windows corresponding to the menu nodes L21, L22, L23, L31, L32, L33, L34, L35 and L36 are all child windows under the parent window. Further, the window corresponding to the menu node L21 is a parent window of the windows corresponding to the menu nodes L31 and L32. The window corresponding to the menu node L22 is the parent window of the window corresponding to the menu node L33. The window corresponding to the menu node L23 is the parent window of the windows corresponding to the menu nodes L31, L32 and L33.
In this embodiment, the menu nodes L21, L22, L23 are windows corresponding to a live video preview mode, a media management mode, and a setting mode, respectively. The branch menu corresponding to the live video preview mode includes a menu node L11, a menu node L21, a menu node L31, and a menu node L32. The branch menu corresponding to the media management mode includes a menu node L11, a menu node L22, and a menu node L33. The branch menu corresponding to the setting mode includes a menu node L11, a menu node L23, a menu node L34, a menu node L35, and a menu node L36.
It can be appreciated that the deeper the levels of the preset menu tree, the more nesting levels between windows, the nesting between windows will occupy a considerable amount of memory resources, which is likely to result in insufficient memory resources. Referring to fig. 4 again, the probability of data sharing between adjacent function levels, such as menu node L21 and menu node L31, is high, and the probability of data sharing is lower the more the function levels differ, such as menu node L11 and menu node L31. Therefore, by controlling the preset menu tree level, the application requirement of the endoscope is met, and the problem that more memory is occupied due to nesting of windows can be solved.
S33, displaying the target window.
The functions with more memory resource requirements of the user interaction function comprise windows, character strings, word libraries and UI pictures. In this implementation, displaying the target window includes: and displaying the target window according to the corresponding relation between the user interaction function and the window. The corresponding relation comprises a double buffer window corresponding to the video playback function, and a dialog box window or a common window corresponding to other user interaction functions except the video playback function.
The windows comprise a dialog box window, a common window and a double buffer window, and the functions and interaction effects supported by the windows are gradually enhanced from the dialog box window, the common window to the double buffer window, and the required memory resources are also gradually increased. Therefore, under the condition of meeting the service function requirement, the dialog box window is preferably selected, and the common window or the double buffer window is avoided as much as possible, so that the use of memory resources is reduced. The functions such as video playback and the like can be played only by the double buffer windows, and at the moment, the double buffer windows are selected for display.
In some embodiments, the method further comprises: and destroying other pictures along with destroying the window except for the picture used by the target window and the picture used by the child window under the parent window in the parent window.
In terms of UI picture loading, only the following two cases are allowed for picture caching: (1) a picture used by a current window (i.e., a target window); (2) pictures in the parent window used by the child window simultaneously. Other UI pictures are destroyed along with the destruction of the window, buffering is not needed, and the UI pictures are reloaded when the window is redrawn next time.
In some embodiments, the method further comprises: and loading only the character strings corresponding to the language used by the user interaction function or the character strings corresponding to the current function mode.
The character string is used as a data resource, and a certain memory is required to be occupied, especially when the endoscope supports multiple languages, the memory space occupied by the character string is linearly increased. To save memory resources, the string is dynamically loaded according to a string loading policy. The character string loading strategy comprises the following steps: (1) loading only the current language-dependent character strings; (2) loading only the character string under the current function operation. For example, the menu nodes L21, L22, and L23 are windows corresponding to the live video preview mode, the media management mode, and the setting mode, respectively, so that the character strings in the live video preview mode, the media management mode, and the setting mode are relatively independent, and when the menu node L21 and its subfunctions are operated, only the character string corresponding to the function mode corresponding to the menu node L21 is loaded, and when the menu node L21 function is exited, the corresponding character string is released.
In some embodiments, the method further comprises: and cutting a word stock of the endoscope according to the user interaction function.
The vector word library of full characters has at least ten megabytes in size, the memory pressure on the endoscope is large when fully loaded, and most characters cannot be referenced. Because the endoscope does not have the condition that a user inputs characters, and the characters to be displayed are determined in design, only the characters required by the project (namely the user interaction function) are reserved by cutting a word stock, so that more than ten times of memory space can be saved.
With the increase of the running time of the endoscope system, memory space is easy to generate memory fragments, and even if the idle memory of the system is relatively large, the memory is insufficient for some functions requiring continuous physical memory, so that the problem of memory allocation failure is easy to cause. In order to solve the above problems, memory compression is adopted to perform memory reclamation, and a large amount of memory fragments can be merged into a large available memory block, and the embodiment of the invention provides two memory compression modes as shown in fig. 5 and 6.
As shown in fig. 5, as an embodiment of the present invention, the method further includes an endoscope memory management method S500, including:
S51, scanning a plurality of memory fragments of the endoscope.
S52, compressing the memory fragments at fixed time.
A small partition in main memory that is generated during memory allocation and cannot be used by a user operation is called a memory fragment. Memory fragmentation exists in two ways, namely internal fragmentation and external fragmentation. The internal debris generation process is as follows: because all memory allocation must start at an address that is divisible by 4, 8, or 16 (depending on the processor architecture) or because of the limitations of the MMU's paging mechanism, it is determined that the memory allocation algorithm can only allocate blocks of memory of a predetermined size to the guest. It is assumed that when a 43 byte memory block is requested, there is no memory of the proper size, so that a bit of slightly larger bytes, e.g., 44 bytes, 48 bytes, etc., may be obtained, and thus the extra space created by rounding the required size is called internal fragmentation. The external debris generation process is as follows: frequent allocation and reclamation of physical pages can result in a large number of consecutive and small blocks of pages interspersed among the allocated pages, creating external fragmentation. It is assumed that there is a block of contiguous free memory space of 100 units in total, ranging from 0 to 99. A block of memory, e.g., 10 units, is applied from the memory block, and the applied block of memory is in the interval of 0-9. Continuing to apply for a block of memory, say 5 units, the second block should have a memory block in the interval 10-14. If the first memory block is released, then a memory block greater than 10 units, such as 20 units, is applied. Since the memory block just released cannot satisfy the new request, only 20 units of memory blocks can be allocated starting from 15. The state of the whole memory space is 0-9 idle, 10-14 occupied, 15-34 occupied and 25-99 idle. Wherein 0-9 is a memory fragment. If 10-14 are occupied all the time and the space applied later is larger than 10 units, 0-9 is never used and becomes external fragments.
Aiming at the characteristics that the memory fragments are more in quantity and can not be utilized, the method for compressing the memory fragments at fixed time comprises the following steps: collecting the memory fragments; and merging the plurality of memory fragments to obtain the available memory. Wherein the available memory capacity is much greater than the capacity of the memory fragments.
The endoscope system starts a timing task, and assuming a clock cycle of 1 second, performs memory compression once when the accumulated count reaches a compression time (e.g., 5 minutes), and so on. As shown in fig. 6, as an embodiment of the present invention, the method further includes an endoscope memory management method S600, including:
s61, scanning a plurality of memory fragments of the endoscope.
S62, compressing the memory fragments when the functional mode is switched.
The demand for contiguous physical memory typically increases abruptly during a functional mode switch. The memory recovery response rate of the continuous physical blocks can be improved in a memory compression mode, so that the target function mode has enough continuous physical memory which can be allocated, and the stable operation of service functions in the target function mode is not affected.
As shown in fig. 7, in some embodiments, the method further includes an endoscope memory management method S700, including:
And S71, determining a memory allocation strategy according to the function executed in the current function mode.
And S72, according to the memory allocation strategy, when the function is executed, releasing the variable or object used by the function.
The memory allocation policy includes static memory allocation and dynamic memory allocation. The static memory is automatically allocated by the system and automatically released by the system. Static memory is allocated in a stack, which is a storage structure. If a main function calls another function, the called function is pushed into a stack. Executing the called function makes all memory spaces allocated by the system for the function pop one by one, and the completion of the pop is the completion of the execution of the called function, and the memory spaces allocated by the system for the static variables are released after the completion of the execution in the program. Dynamic memory is manually allocated by a programmer, manually released, and function termination is not automatically released by the system. Dynamic memory is allocated in a heap, which is not a storage structure, and a heap is an ordering way of allocating memory, where the ordering way includes bubbling ordering, insertion ordering, selection ordering, quick ordering, and the like. Because dynamic memory is allocated in the heap, the function is not released after the end of running.
The difference and characteristics of static memory allocation and dynamic memory allocation are as follows: (1) The static memory allocation is completed during compiling, does not occupy CPU resources, is completed during dynamic memory allocation running, and occupies CPU resources during allocation and release; (2) Static memory allocation is allocated on stacks, and dynamic memory is allocated on stacks; (3) Dynamic memory allocation requires support of pointers or reference data types, whereas static memory allocation is not required; (4) The static memory allocation is according to the plan allocation, the size of a memory block is determined before compiling, and the dynamic memory allocation is allocated according to the requirement during operation; (5) The static memory allocation is that the control right of the memory is given to a compiler, and the dynamic memory gives the control right of the memory to a programmer; (6) The running efficiency of the static memory allocation is higher than that of the dynamic memory allocation, because the dynamic memory allocation and release require additional overhead; (7) The dynamic memory management level is severely dependent on the level of the programmer, and improper handling is likely to cause memory leakage.
Taking a process language-oriented software design as an example, global variables and static variables occupy certain memory resources in the whole application operation life cycle and are not released. The global variable is the memory allocated when creating the object, creating the object process: distributing space; recursively creating a parent class object; initializing a member variable; the call structure method creates an object. The static variable is allocated space when class is loaded, the static variable has no relation with the object, and the loading process is as follows: loading the parent class, and if the parent class is already loaded, not loading; initializing static attributes; the static code blocks are initialized in sequence, the premise of the initialization is that space is allocated, and the static variables are not initialized when objects are created later, so the shared information is generally saved by the static variables.
It should be noted that most variables are associated with only a few functions, and need not be retained in memory for a long period of time, particularly large data blocks. Thus, dynamic memory allocation is used for large data blocks, which are released immediately after the associated functional logic has finished running. For partial application, the variable definitions are more, the relevance among the variables is larger, but the memory units occupied by each variable are not more, if dynamic memory allocation is adopted, the execution efficiency is not high. Therefore, objects are used to organize the variables, the objects are dynamically generated, and after the objects are used, the objects are released, so that the memory space is saved, and the running efficiency of the endoscope is improved.
According to the endoscope memory management method provided by the embodiment of the invention, the functions supported by the endoscope are decoupled into the real-time video preview mode, the media management mode and the setting mode, so that at least part of memory resources occupied by each function mode are not shared, and when the current function mode is switched, the memory resources occupied by the current function mode are released. Therefore, the embodiment of the invention improves the utilization rate of the memory resources.
Correspondingly, the embodiment of the invention provides an endoscope memory management device. As shown in fig. 8, the endoscope memory management device 800 includes a first acquisition module 801, a switching module 802, and a first release module 803.
The first obtaining module 801 is configured to obtain a mode switching instruction in a current functional mode, where the current functional mode is any one of a live video preview mode, a media management mode, and a setting mode, and the live video preview mode, the media management mode, and the setting mode are decoupled from each other, so that at least part of memory resources occupied by the functional modes are not shared.
And a switching module 802, configured to switch the current functional mode to the target functional mode pointed by the mode switching instruction.
A first releasing module 803, configured to release the memory resources occupied by the current functional mode.
In some embodiments, embodiments of the present invention provide another endoscope memory management device. As shown in fig. 9, as an embodiment of the present invention, the endoscope memory management device 900 includes a second acquisition module 901, a search module 902, and a display module 903.
The second obtaining module 901 is configured to obtain a function selection instruction when the user interaction function is executed in the current function mode.
The search module 902 is configured to search a preset menu tree according to the function selection instruction, so as to traverse the target window pointed by the function selection instruction step by step, where the preset menu tree includes a branch menu corresponding to each current function mode, and each branch menu includes a parent window and a plurality of child windows under the parent window.
Wherein the child window under each parent window is not more than three.
The display module 903 is configured to display the target window.
The display module 903 is specifically configured to: and displaying the target window according to the corresponding relation between the user interaction function and the window. The corresponding relation comprises a double buffer window corresponding to the video playback function, and a dialog box window or a common window corresponding to other user interaction functions except the video playback function.
As an embodiment of the present invention, the endoscope memory management device 900 further includes:
the destroying module 904 is configured to destroy other pictures along with the destruction of the window, except for the picture used by the target window and the picture used by the child window under the parent window in the parent window.
As an embodiment of the present invention, the endoscope memory management device 900 further includes:
and a loading module 905, configured to load only a character string corresponding to a language used by the user interaction function or a character string corresponding to the current function mode.
As an embodiment of the present invention, the endoscope memory management device 900 further includes:
and a clipping module 906, configured to clip the word stock of the endoscope according to the user interaction function.
As an embodiment of the present invention, the endoscope memory management device 900 further includes:
a scanning module 907 for scanning the endoscope for a number of memory fragments.
A first compression module 908 is configured to compress the plurality of memory fragments at regular time.
As an embodiment of the present invention, the endoscope memory management device 900 further includes:
a scanning module 907 for scanning the endoscope for a number of memory fragments.
The second compression module 909 is configured to compress the plurality of memory fragments when the functional mode is switched.
As an embodiment of the present invention, the endoscope memory management device 900 further includes:
a determining module 910, configured to determine a memory allocation policy according to the function executed in the current functional mode.
And a second releasing module 911, configured to release the variable or object used by the function when the function is executed according to the memory allocation policy.
The product can execute the method provided by the embodiment of the invention, and has the corresponding functional modules and beneficial effects of the execution method. Technical details not described in detail in this embodiment may be found in the methods provided in the embodiments of the present invention.
Fig. 10 is a schematic structural view of an endoscope according to an embodiment of the present invention. As shown in fig. 10, which illustrates a hardware configuration of the endoscope 10 capable of performing the endoscope memory management method in fig. 2 to 3, and fig. 5 to 7.
The endoscope 10 includes at least one processor 101 and a memory 102 communicatively coupled to the at least one processor 101, one processor 101 being illustrated in fig. 10. The memory 102 stores instructions executable by the at least one processor 101 to enable the at least one processor 101 to perform the endoscope memory management method according to any of the method embodiments of the present invention.
The processor 101 and the memory 102 may be connected by a bus or otherwise, for example in fig. 10.
The memory 102 is used as a non-volatile computer readable storage medium for storing non-volatile software programs, non-volatile computer executable programs, and modules, such as program instructions/modules corresponding to the endoscope memory management method in the embodiment of the present invention, for example, each of the modules shown in fig. 8 and 9. The processor 101 executes various functional applications and data processing of the endoscope 10 by running non-volatile software programs, instructions and modules stored in the memory 102, i.e., implements the endoscope memory management method according to any of the method embodiments of the present invention.
The memory 102 may include a storage program area that may store an operating system, at least one application program required for functions, and a storage data area; the storage data area may store data created according to the use of the endoscope memory management device, and the like. In addition, memory 102 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid-state storage device. In some embodiments, memory 102 optionally includes memory remotely located relative to processor 101, which may be connected to a device controlling endoscope memory management via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The one or more modules are stored in the memory 102 and when executed by the one or more processors 101 perform the endoscope memory management method of any of the method embodiments described above, for example, performing the steps described above and shown in fig. 2-3, 5-7, to implement the functions of the respective modules described in fig. 8-9.
In the embodiment of the present application, the memory 102 includes a random access memory 1021, a Flash memory 1022, and an SD memory card 1023, and the random access memory 1021, the Flash memory 1022, and the SD memory card 1023 are memories of the endoscope 10. The ram 1021 is also called as a main memory, and is an internal memory directly exchanging data with the processor 101, and is used for temporarily storing programs, data, and intermediate results. Flash memory 1022 is a non-volatile memory for long-term storage of data. The SD memory card 1023 is removably mounted in the endoscope for storing data at a high speed.
The processor 101 can read data and instructions from the random access memory 1021, the Flash memory 1022, and the SD memory card 1023 by way of a bus or the like. Assuming that a program corresponding to each function or a plurality of sub-functions included in the function includes code data, read-only data, read-write data, and initialization data, when the program is running, flash memory 1022 allocates a memory space for storing the code data and the read-only data, and ram 1021 allocates a memory space for storing the read-write data and the initialization data, that is, the code data and the read-only data occupy memory resources of Flash memory 1022, and the read-write data and the initialization data occupy memory resources of ram 1021.
For example, the processor 101 includes a CPU and a controller (not shown), when executing a function in the current functional mode, the CPU receives an operation instruction, and the corresponding program instruction in the hard disk is directly loaded into at least one memory of the random access memory 1021, the Flash memory 1022, and the SD memory card 1023, then performs an addressing operation on at least one memory of the random access memory 1021, the Flash memory 1022, and the SD memory card 1023, then translates the instruction loaded into at least one memory of the random access memory 1021, the Flash memory 1022, and the SD memory card 1023, and finally sends an operation signal to the controller to implement the running of the program or the processing of the data.
Embodiments of the present invention also provide a non-transitory computer readable storage medium storing computer executable instructions for enabling an endoscope to perform the endoscope memory management method according to any of the method embodiments of the present invention, for example, performing the steps shown in fig. 2 to 3 and fig. 5 to 7 described above, and implementing the functions of the modules described in fig. 8 to 9.
Embodiments of the present invention also provide a computer program product comprising a computer program stored on a non-transitory computer readable storage medium, the computer program comprising program instructions which, when executed by a computer, cause the computer to perform the endoscope memory management method in any of the method embodiments described above, for example, to perform the steps described above and shown in fig. 2 to 3 and fig. 5 to 7, and implement the functions of the modules described in fig. 8 to 9.
It should be noted that the above-described apparatus embodiments are merely illustrative, and the units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed over a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
From the above description of embodiments, it will be apparent to those skilled in the art that the embodiments may be implemented by means of software plus a general purpose hardware platform, or may be implemented by hardware. Those skilled in the art will appreciate that all or part of the processes implementing the methods of the above embodiments may be implemented by a computer program for instructing relevant hardware, where the program may be stored in a computer readable storage medium, and where the program may include processes implementing the embodiments of the methods described above. The storage medium may be a magnetic disk, an optical disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), or the like.
From the above description of embodiments, it will be apparent to those skilled in the art that the embodiments may be implemented by means of software plus a general purpose hardware platform, but may also be implemented by means of hardware. Those skilled in the art will appreciate that all or part of the processes implementing the methods of the above embodiments may be implemented by a computer program for instructing relevant hardware, where the program may be stored in a computer readable storage medium, and where the program may include processes implementing the embodiments of the methods described above. The storage medium may be a magnetic disk, an optical disk, a Read-Only Memory (ROM), a random access Memory (RandomAccessMemory, RAM), or the like.
Finally, it should be noted that: the above embodiments are only for illustrating the technical solution of the present invention, and are not limiting; the technical features of the above embodiments or in the different embodiments may also be combined within the idea of the invention, the steps may be implemented in any order, and there are many other variations of the different aspects of the invention as described above, which are not provided in detail for the sake of brevity; although the invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit of the invention.

Claims (8)

1. An endoscope memory management method, comprising:
in a current functional mode, acquiring a mode switching instruction, wherein the current functional mode is any one mode of a real-time video preview mode, a media management mode and a setting mode, and the real-time video preview mode, the media management mode and the setting mode are mutually decoupled so as to enable at least part of memory resources occupied by each functional mode to be unshared;
switching the current functional mode to be a target functional mode pointed by the mode switching instruction;
releasing the memory resources occupied by the current functional mode;
acquiring a function selection instruction when executing a user interaction function in the current function mode;
searching a preset menu tree according to the function selection instruction to traverse a target window pointed by the function selection instruction step by step, wherein the preset menu tree comprises branch menus corresponding to each current function mode, and each branch menu comprises a father window and a plurality of child windows under the father window;
displaying the target window according to the corresponding relation between the user interaction function and the window, wherein the corresponding relation comprises a double buffer window corresponding to the video playback function, and a dialog box window or a common window corresponding to other user interaction functions except the video playback function;
And destroying other pictures along with destroying the window except for the picture used by the target window and the picture used by the child window under the parent window in the parent window.
2. The method of claim 1, wherein the child window under each of the parent windows is no more than three.
3. The method according to any one of claims 1-2, wherein the method further comprises:
and loading only the character strings corresponding to the language used by the user interaction function or the character strings corresponding to the current function mode.
4. The method according to any one of claims 1-2, wherein the method further comprises:
and cutting a word stock of the endoscope according to the user interaction function.
5. The method according to claim 1, wherein the method further comprises:
scanning a plurality of memory fragments of the endoscope;
and compressing the memory fragments at fixed time.
6. The method according to claim 1, wherein the method further comprises:
scanning a plurality of memory fragments of the endoscope;
and compressing the memory fragments when the functional mode is switched.
7. The method according to claim 1, wherein the method further comprises:
Determining a memory allocation strategy according to the function executed in the current function mode;
and according to the memory allocation strategy, when the function is executed, releasing the variable or object used by the function.
8. An endoscope, comprising:
at least one processor; the method comprises the steps of,
a memory communicatively coupled to the at least one processor; wherein,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the endoscope memory management method of any one of claims 1-7.
CN202010412915.9A 2020-05-15 2020-05-15 Endoscope memory management method and endoscope Active CN111597046B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN202010412915.9A CN111597046B (en) 2020-05-15 2020-05-15 Endoscope memory management method and endoscope
PCT/CN2021/088777 WO2021227803A1 (en) 2020-05-15 2021-04-21 Endoscope memory management method and endoscope

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010412915.9A CN111597046B (en) 2020-05-15 2020-05-15 Endoscope memory management method and endoscope

Publications (2)

Publication Number Publication Date
CN111597046A CN111597046A (en) 2020-08-28
CN111597046B true CN111597046B (en) 2023-12-22

Family

ID=72191070

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010412915.9A Active CN111597046B (en) 2020-05-15 2020-05-15 Endoscope memory management method and endoscope

Country Status (2)

Country Link
CN (1) CN111597046B (en)
WO (1) WO2021227803A1 (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111597046B (en) * 2020-05-15 2023-12-22 深圳市道通科技股份有限公司 Endoscope memory management method and endoscope
CN112338919B (en) * 2020-10-30 2022-03-04 珠海一微半导体股份有限公司 Robot operation control method, robot and chip
CN116028383B (en) * 2022-08-22 2023-10-20 荣耀终端有限公司 Cache management method and electronic equipment

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103188453A (en) * 2011-12-31 2013-07-03 联想(北京)有限公司 Control method, device and electronic device of television playing
CN103716535A (en) * 2013-12-12 2014-04-09 乐视致新电子科技(天津)有限公司 Method for switching photographing mode, and electronic device
CN104735359A (en) * 2015-04-09 2015-06-24 广东欧珀移动通信有限公司 Mobile terminal camera running method and device
CN108833960A (en) * 2018-06-14 2018-11-16 青岛海信传媒网络技术有限公司 A kind of method and device of audiovisual applications switching

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP4643481B2 (en) * 2006-03-23 2011-03-02 オリンパスメディカルシステムズ株式会社 Image processing device
CN102521053B (en) * 2011-12-13 2014-04-16 深圳市安云信息科技有限公司 Memory system and on-line switching method of FC (Fiber Channel) port working mode
JP5810248B2 (en) * 2013-10-02 2015-11-11 オリンパス株式会社 Endoscope system
JP2019534490A (en) * 2016-08-12 2019-11-28 ボストン サイエンティフィック サイムド,インコーポレイテッドBoston Scientific Scimed,Inc. Distributed interactive medical visualization system with primary / secondary interaction functions
CN111597046B (en) * 2020-05-15 2023-12-22 深圳市道通科技股份有限公司 Endoscope memory management method and endoscope

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103188453A (en) * 2011-12-31 2013-07-03 联想(北京)有限公司 Control method, device and electronic device of television playing
CN103716535A (en) * 2013-12-12 2014-04-09 乐视致新电子科技(天津)有限公司 Method for switching photographing mode, and electronic device
CN104735359A (en) * 2015-04-09 2015-06-24 广东欧珀移动通信有限公司 Mobile terminal camera running method and device
CN108833960A (en) * 2018-06-14 2018-11-16 青岛海信传媒网络技术有限公司 A kind of method and device of audiovisual applications switching

Also Published As

Publication number Publication date
WO2021227803A1 (en) 2021-11-18
CN111597046A (en) 2020-08-28

Similar Documents

Publication Publication Date Title
CN111597046B (en) Endoscope memory management method and endoscope
US11531625B2 (en) Memory management method and apparatus
CN108132890B (en) Garbage recycling method, device and equipment for memory chip and storage medium
US9400754B2 (en) Asynchronous swap mechanism and page eviction from memory
US9086920B2 (en) Device for managing data buffers in a memory space divided into a plurality of memory elements
JP2006351004A (en) Memory management method of mobile terminal
JP4753549B2 (en) Cache memory and system
US20140325177A1 (en) Heap management using dynamic memory allocation
US8031208B2 (en) Drawing apparatus and method for processing plural pixels in parallel
CN114302040A (en) Method for sharing single camera by multiple applications and related product
US7552285B2 (en) Line fill techniques
US7900010B2 (en) System and method for memory allocation management
WO2021164560A1 (en) Multi-core chip and scheduling method therefor
KR20050076702A (en) Method for transferring data in a multiprocessor system, multiprocessor system and processor carrying out this method
US9778969B2 (en) Automatic memory leak detection
CN110445874B (en) Session processing method, device, equipment and storage medium
CN111198843A (en) File system writing acceleration method based on bus control on application processor chip
CN113127213A (en) Method, device, equipment and storage medium for supporting multi-application data sharing
CN114296658B (en) Storage space allocation method and device, terminal equipment and storage medium
CN107797757B (en) Method and apparatus for managing cache memory in image processing system
CN115495020A (en) File processing method and device, electronic equipment and readable storage medium
CN112905497B (en) Memory management method and device, electronic equipment and storage medium
CN111984197B (en) Computer cache allocation method
US6535969B1 (en) Method and apparatus for allocating free memory
CN109634877B (en) Method, device, equipment and storage medium for realizing stream operation

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant