Reference management method and garbage collection method

By recording the reference address table of application data in the embedded operating system, the identification problem of unrecorded reference data is solved, the application data is accidentally deleted and garbage collection performance is improved, and the application stability and efficient use of memory is ensured. .

CN119088561AActive Publication Date: 2024-12-06BEIJING TONGFANG MICROELECTRONICS
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202411202239.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-29
Publication Date
2024-12-06
Estimated Expiration
2044-08-29

AI Technical Summary

Technical Problem

The existing reference data management method cannot identify the referenced application data in some scenarios, resulting in the possibility of mistakenly considering junk data and being deleted, causing an empty exception.

Method used

In the runtime environment of the embedded operating system, when the target application data is referenced by the target variable, its logical address is written to the physical address of the target variable, and the logical address corresponding to the physical address is written to the reference address table, and the management Application data references that are not recorded in the reference data to avoid mistaken deletion.

Benefits of technology

It effectively avoids the deletion of application data that mistakenly considers junk data, improves the stability and garbage collection performance of the application, and ensures the accuracy of reference relationships and the efficiency of memory usage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119088561A_ABST
    Figure CN119088561A_ABST
Patent Text Reader

Abstract

The invention discloses reference management and garbage collection of application data. The application data reference management method comprises the steps that when it is detected that target application data is referenced by a target variable, and the target variable belongs to a target variable type, a logic address of the target application data is written into a physical address of the target variable; and taking the logic address corresponding to the physical address of the target variable as a reference address, and writing the reference address into a reference address table. According to the technical scheme, the reference address table is used for managing application data reference which is not recorded in the reference array, the application data are prevented from being mistakenly regarded as junk data and deleted, null exception caused by reference of the inexistent application data is avoided, the reference address table records the reference address instead of the logic address of the application data, and the application data can be stored in the application data. Content in an application data reference counter or a reference address table is prevented from being synchronously modified when the reference relation is cleared, and application execution efficiency is guaranteed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a reference management and garbage collection method for application data. Background Art

[0002] WebAssembly (wasm for short) belongs to the virtual instruction set architecture. In an embedded operating system based on the WebAssembly virtual machine, application data is data created by calling the API (Application Programming Interface) provided by the runtime environment (RTE) during the installation of the application module or the running of the application. Depending on the type of application data, the application data is allocated in volatile storage space or non-volatile storage space.

[0003] Normally, the logical address or pseudo address (hereinafter referred to as logical address) of application data can be assigned to local data (also called temporary variables) or module global data (also called global variables). The process of variables recording the logical address of application data is called reference. The referenced application data is active, while the unreferenced application data is called garbage data. Recording the logical address of application data by creating reference data (also called reference array) for the application is called direct reference. Whether the application data is referenced can be identified by querying the reference data.

[0004] Referencing application data and recycling garbage data are widely used in the development process of applications. However, the existing implementation method of recording the reference status of application data only through reference data, in the specific scenario where the logical address of the referenced application data is not recorded in the referenced data, the application cannot identify whether such application data is referenced, and may mistake such application data for garbage data and delete it by mistake. When this happens, a null exception will occur because the application references non-existent application data. Summary of the invention

[0005] The embodiment of the present invention provides a reference management method and a garbage collection method for application data, so as to provide a new way to manage referenced application data not recorded in the reference data through a reference address table, so as to avoid mistakenly deleting such referenced application data as garbage data.

[0006] According to one aspect of an embodiment of the present invention, a method for managing references of application data is provided, which is executed by a runtime environment in an embedded operating system installed in a restricted device. The method includes:

[0007] When it is detected that the target application data is referenced by the target variable and the target variable belongs to the target variable type, writing the logical address of the target application data into the physical address of the target variable;

[0008] The logical address corresponding to the physical address of the target variable is written as the reference address into the reference address table.

[0009] According to another aspect of an embodiment of the present invention, a garbage collection method is provided, which is executed by a runtime environment in an embedded operating system, and the embedded operating system is installed in a restricted device. The method includes:

[0010] When it is detected that a garbage collection condition for the target application is met, obtaining each application data created during the execution of the target application;

[0011] Identifying junk data in each application data according to the reference address table and the reference data corresponding to the target application;

[0012] Wherein, the reference address table is maintained by the reference management method for application data as described in any one of the embodiments of the present invention;

[0013] Perform garbage collection operations based on the identified garbage data.

[0014] According to another aspect of an embodiment of the present invention, there is also provided a reference management device for application data, which is configured in a runtime environment of an embedded operating system, and the embedded operating system is installed in a restricted device, and the device includes:

[0015] A logical address writing module, used for writing the logical address of the target application data into the physical address of the target variable when it is detected that the target application data is referenced by the target variable and the target variable belongs to the target variable type;

[0016] The reference address writing module is used to write the logical address corresponding to the physical address of the target variable as the reference address into the reference address table.

[0017] According to another aspect of an embodiment of the present invention, there is further provided a garbage collection device, which is configured in a runtime environment of an embedded operating system, wherein the embedded operating system is installed in a restricted device, and the device comprises:

[0018] An application data acquisition module, for acquiring various application data created by the target application during execution when it is detected that the garbage collection condition for the target application is met;

[0019] A junk data identification module, used to identify junk data in each application data according to a reference address table and reference data corresponding to the target application;

[0020] Wherein, the reference address table is maintained by the reference management method for application data as described in any one of the embodiments of the present invention;

[0021] The garbage collection processing module is used to perform garbage collection operations based on the identified garbage data.

[0022] According to another aspect of an embodiment of the present invention, a restricted device is further provided, wherein an embedded operating system is installed on the restricted device, a runtime environment is executed in the embedded operating system, and the restricted device includes:

[0023] at least one processor; and

[0024] a memory communicatively connected to the at least one processor; wherein,

[0025] The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the reference management method of application data as described in any one of the embodiments of the present invention, or execute the garbage collection method as described in any one of the embodiments of the present invention.

[0026] According to another aspect of the embodiments of the present invention, a terminal is provided, comprising the restricted device as described in any one of the embodiments of the present invention.

[0027] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is also provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement a reference management method for application data as described in any one of the embodiments of the present invention, or to implement a garbage collection method as described in any one of the embodiments of the present invention when executed.

[0028] According to another aspect of an embodiment of the present invention, a computer program product is also provided, which includes a computer program, and when the computer program is executed by a processor, it implements the reference management method for application data as described in any one of the embodiments of the present invention, or implements the garbage collection method as described in any one of the embodiments of the present invention.

[0029] The technical solution of the embodiment of the present invention is to write the logical address of the target application data into the physical address of the target variable when it is detected that the target application data is referenced by the target variable and the target variable belongs to the target variable type; and write the logical address corresponding to the physical address of the target variable as the reference address into the reference address table. Furthermore, when it is detected that the garbage collection conditions for the target application are met, the application data created by the target application during execution are obtained; based on the reference address table and the reference data corresponding to the target application, the garbage data in the application data is identified; the technical means of performing garbage collection operations based on the identified garbage data can use the reference address table to manage all application data references that are not recorded in the reference data, thereby avoiding such application data from being mistakenly identified as garbage data and deleted, thereby avoiding null exceptions caused by referencing non-existent application data. In addition, the reference address table records the reference address instead of the logical address of the application data, thereby avoiding the need to synchronously modify the application data reference counter or the content in the reference address table when the reference relationship is cleared, thereby ensuring the execution efficiency of the application to a certain extent. In addition, when the application applies for garbage collection or is deleted, the operating system can identify whether the application data is garbage data based on the reference address table, thereby avoiding setting a garbage data flag in the application data, thereby avoiding excessive erasing of the memory and improving garbage collection performance.

[0030] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0032] Figure 1 is a flow chart of a method for managing references of application data provided in an embodiment of the present invention;

[0033] Figure 2 is a flowchart of another method for managing references of application data provided according to an embodiment of the present invention;

[0034] Figure 3 is a flowchart of a garbage collection method provided according to an embodiment of the present invention;

[0035] Figure 4 is a flow chart of another garbage collection method provided according to an embodiment of the present invention;

[0036] Figure 5 It is a flowchart of a specific application scenario applicable to the embodiment of the present invention;

[0037] Figure 6 This is a schematic diagram of a data reference relationship stored only by referencing data applicable to the application scenario of the embodiment of the present invention;

[0038] Figure 7 It is a schematic diagram applicable to the application scenario of the embodiment of the present invention, which stores the reference relationship of application data through reference data and reference address table at the same time;

[0039] Figure 8 It is a schematic diagram of a reference address stored by four-byte data applicable to the application scenario of the embodiment of the present invention;

[0040] Fig. 9 It is a schematic diagram of member data of application data A referencing application data B applicable to the application scenario of an embodiment of the present invention;

[0041] Fig.10 is a schematic diagram of the structure of a reference management device for application data provided according to an embodiment of the present invention;

[0042] Fig.11 is a structural schematic diagram of a garbage collection device provided according to an embodiment of the present invention;

[0043] Fig.12 is a structural schematic diagram of a restricted device provided by an embodiment of the present invention;

[0044] Fig.13 is a structural diagram of a terminal provided according to an embodiment of the present invention. DETAILED DESCRIPTION

[0045] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0046] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0047] Figure 1 A flowchart of a method for managing the reference of application data provided in an embodiment of the present invention. This embodiment can be applied to the case where, when a specific variable is used to reference application data, the reference information is stored in a reference address table. The method can be executed by a device for managing the reference of application data. The device can be implemented in the form of hardware and / or software and can generally be configured in a restricted device (for example, various security elements or smart cards, etc.) equipped with an embedded operating system.

[0048] The method in this embodiment is executed by a runtime environment in an embedded operating system. The runtime environment is a secure runtime environment for executing virtual machines on restricted resources such as smart cards or secure elements, and can be regarded as an ultra-lightweight container. The application runs in the runtime environment and can be completely isolated from the native functions of the embedded operating system.

[0049] Correspondingly, such as Figure 1 As shown, the method includes:

[0050] S110. When it is detected that the target application data is referenced by the target variable and the target variable belongs to the target variable type, the logical address of the target application data is written into the physical address of the target variable.

[0051] The target application data is generated during the execution of the target application running in the logical channel. The logical channel can be understood as a concept for establishing a communication connection between the host and the restricted device. It allows multiple independent communication channels to be established between the host and the restricted device at the same time, each channel has its own command and response stream, and is isolated from each other. The target application can be understood as an application based on WebAssembly.

[0052] In this embodiment, establishing a reference can be understood as recording the logical address of application data during the application program writing process to facilitate rapid locating of the application data in the business process. The process of recording the logical address of application data is usually an assignment operation.

[0053] Accordingly, detecting that the target application data is referenced by the target variable may include:

[0054] When the logical address of the target application data is assigned to the target variable, it is determined that it is detected that the target application data is referenced by the target variable.

[0055] Among them, assigning the logical address of the target application data to the target variable means providing the logical address of the target application data as a whole to the target variable. If the logical address of the application data is decomposed into single bytes and written into the module global data or application data one by one when establishing a reference, the reference address cannot be written into the reference address table, and the operating system considers that the application data has not been referenced.

[0056] As mentioned above, the data elements in the reference data can be directly used to record the logical address of the target application data. If the target variable belongs to the reference data, the logical address of the application data can be directly recorded in the reference data. Then, the application data can be obtained by querying the data elements in the reference data. Among them, when the application module creates an application, the reference data is allocated by the runtime environment of the operating system, and each application has only one reference data (or reference array).

[0057] However, some types of variables will not be recorded in the reference data. For example, the logical address of a certain application data A is recorded in the variable of application data B as the data content of application data B. That is, when application data B references application data A as a variable, the logical address of application data A will not be recorded in the reference data.

[0058] In a specific example, if the logical address of application data (typically, persistent data) is recorded as the content of another application data (typically, persistent data) and is not recorded in the reference array, there is no connection between the two application data. At this time, the application cannot identify whether it is referenced according to the reference data type. Alternatively, the logical address of the application data is recorded in the module global variable data, and the reference cannot be identified in the module global variable data by the reference data type, so the application data may also be mistaken for garbage data.

[0059] In this embodiment, mainly for this type of variables, the references to application data are stored.

[0060] Correspondingly, the target variable types may include: persistent data, module global data, temporary static variable data, and temporary dynamic variable data.

[0061] Among them, persistent data refers to a type of non-volatile storage data created by calling the storage space allocation interface provided by the operating system runtime environment during the installation or operation of the application module, and its initial value content is 0. Persistent data belongs to the application itself, and the persistent data can be written and read through the interface or pointer variable provided by the operating system runtime environment, and the virtual machine instruction can directly access the persistent data through the pointer variable.

[0062] Module global data refers to global data that is visible to the entire module and can be modified by applications within the module, such as the application's global data or the application's global variable stack.

[0063] Temporary static variable data means that whenever the embedded operating system is reset, the resource state will be reset to 0. This resource state will not be shared between applications and is usually used to store data related to a specific session or transaction to ensure security and data isolation. Temporary dynamic variable data means that during the interaction with the application, the resource state will be retained until the application is deselected, and the resource state will be cleared to 0. This resource is usually used to share temporary data between applications, such as temporary counters or caches.

[0064] In this embodiment, when the target variable that references the target application data belongs to any of persistent data, module global data, temporary static variable data, and temporary dynamic variable data, the references of the above target variables to the application data will not be recorded in the reference data. Therefore, additional processing is required for these types of variables to effectively record the references of the target variables to the target application data.

[0065] Of course, those skilled in the art will appreciate that the target variable types listed above are merely examples, and in fact, all target variable types that cannot store reference relationships in reference data can be applied to the technical solutions of the various embodiments of the present invention.

[0066] S120. Write the logical address corresponding to the physical address of the target variable into the reference address table as a reference address.

[0067] In this embodiment, after the logical address of the target application data is assigned to the target variable, the logical address of the target application data needs to be written into the physical address of the target variable. Afterwards, if the physical address of the target variable can be saved, the target application data can be indirectly obtained.

[0068] In this embodiment, the logical address corresponding to the physical address of the target variable is first obtained, and the logical address corresponding to the physical address of the target variable is stored as a reference address in a reference address table, and the logical address of the target application data is indirectly stored through the reference address table.

[0069] Correspondingly, the reference address table stores one or more reference addresses, each of which can index the physical address of a variable (or data), and the physical address of the variable stores the logical address of the referenced application data. That is, the logical address corresponding to the physical address that records the logical address of the application data is called the reference address. Based on the uniqueness of the reference address, a reference address table is established to record the reference address of the application data that is not recorded in the reference data.

[0070] Through the above settings, the reference address table can be used to manage references to all application data that are not recorded in the reference data, avoiding situations where such application data is mistakenly regarded as junk data and deleted, thereby avoiding null exceptions caused by referencing non-existent application data.

[0071] The technical solution of the embodiment of the present invention, through the technical means of writing the logical address of the target application data into the physical address of the target variable when it is detected that the target application data is referenced by the target variable and the target variable belongs to the target variable type; writing the logical address corresponding to the physical address of the target variable as the reference address into the reference address table, can use the reference address table to manage all application data references that are not recorded in the reference data, avoid such application data being mistaken for garbage data and being deleted, thereby avoiding null exceptions caused by referencing non-existent application data. In addition, the reference address table records the reference address instead of the logical address of the application data, avoids the need to synchronously modify the application data reference counter or the content in the reference address table when the reference relationship is cleared, and ensures the execution efficiency of the application to a certain extent.

[0072] Figure 2 A flowchart of another method for managing references to application data provided in an embodiment of the present invention. This embodiment is optimized based on the above embodiments. In this embodiment, the operation of "writing the logical address corresponding to the physical address of the target variable as the reference address into the reference address table" is concretized.

[0073] Correspondingly, such as Figure 2 As shown, the method may specifically include:

[0074] S210: When it is detected that the target application data is referenced by the target variable and the target variable belongs to the target variable type, write the logical address of the target application data into the physical address of the target variable.

[0075] S220. According to the physical address of the target variable, obtain the logical address of the target variable and the offset of the logical address of the target application data in the target variable.

[0076] In this embodiment, there is a preset mapping relationship between the physical memory space and the virtual memory space. After the physical address of the target variable is obtained, the logical address of the physical variable can be obtained accordingly.

[0077] When the logical address of the target application data is stored as a variable member in the target variable, the offset of the logical address of the target variable in the target variable can be known at the same time.

[0078] In a specific example, if the logical address of the target application data is the first variable member in the target variable, the offset of the logical address of the target application data in the target variable is 0; if a 4-byte variable member has been stored in the target variable before the logical address of the target application data is stored, the offset of the logical address of the target application data in the target variable is 4 bytes.

[0079] S230 , combining the logical address of the target variable and the offset of the logical address of the target application data in the target variable to obtain a reference address, and writing the combined reference address into a reference address table.

[0080] The reference address is obtained by combining the logical address of the target variable and the offset of the logical address of the target application data in the target variable. Based on the reference address, the logical address of the target application data can be located step by step.

[0081] In an optional implementation of this embodiment, in the reference address table, each reference address is represented by four bytes of data with an identifier;

[0082] The identifier is used to indicate that the four-byte data is a reference address, the first two bytes of the four-byte data are used to store the logical address of the referencer data, and the last two bytes of the four-byte data are used to store the offset of the logical address of the referenced data in the referencer data.

[0083] As mentioned above, if the target application data is referenced by the target variable, the target variable is the referencer data, and the target application data is the referenced data. That is, when a four-byte data carries a specific identifier, such as "REF_FLAG", it indicates that the four-byte data is a reference address, wherein the first two bytes of the four-byte data are the logical address of the target variable, and the last two bytes of the four-byte data are the offset of the logical address of the target application data in the target variable.

[0084] In a specific example, the application data type includes two types: temporary array and persistent array. The temporary array includes two types: temporary static variable array (abbreviated as ASR) and temporary dynamic variable array (abbreviated as ADR). The persistent array (abbreviated as NVR) is the data stored in the non-volatile storage space.

[0085] According to the logical addresses of application data being recorded in different types of variables, the references to application data can be divided into temporary references and persistent references. Using variables stored in volatile storage space (such as local data, module global data, ASR, ADR) to record the logical addresses of application data is called a temporary reference, and using variables stored in non-volatile storage space (reference data, NVR) to record the logical addresses of application data is called a persistent reference. When the operating system loses power or is reset, all data in the volatile storage space is lost and temporary references are canceled, which will result in unreferenced garbage data, while persistent references will not be lost.

[0086] In an optional implementation of the embodiment, the reference address table is stored in the non-volatile storage space of the restricted device. At this time, even if the operating system loses power or resets, the unreferenced garbage data generated by the temporary reference cancellation can be cleared in time according to the reference address table.

[0087] The technical solution of the embodiment of the present invention obtains the logical address of the target variable and the offset of the logical address of the target application data in the target variable according to the physical address of the target variable, combines the reference address and stores it in the reference address table, and uniformly records the application data references that are not recorded in the reference data in the reference address table, thereby avoiding the situation where such application data is mistakenly regarded as junk data and deleted by mistake, and can effectively avoid the null exception caused by referencing non-existent application data.

[0088] Based on the above embodiments, the method may further include:

[0089] When it is detected that the target application data is referenced by the target variable and the target variable belongs to the referenced data, only the logical address of the target application data is written into the physical address of the target variable.

[0090] In this optional implementation, if the target variable belongs to the reference data, it means that the target variable is an element in the reference data, and the logical address of the target application data is directly recorded in the reference data. In this case, there is no need to repeatedly record the logical address corresponding to the physical address of the target variable in the reference address table, and therefore, only the logical address of the target application data is written into the physical address of the target variable.

[0091] Based on the above embodiments, the method may further include:

[0092] When it is detected that the target application data is referenced by the target variable and the target variable belongs to local data, only the logical address of the target application data is written into the physical address of the target variable.

[0093] Among them, local data refers to data defined in the application and visible only within a specific scope, and its lifecycle is limited to the specific scope. It is usually a temporary variable or function parameter defined inside a function, method, or code block, and can only be accessed and used within its scope.

[0094] In this optional implementation, when the logical address of the application data is recorded in the local data (also called temporary variable), there is no need to manage the reference, and as the local data is recycled (typically, stack recycling), the reference relationship naturally ceases to exist. Therefore, it is also sufficient to only write the logical address of the target application data into the physical address of the target variable.

[0095] Based on the above content, three typical situations of reference relationships are summarized:

[0096] 1. When the logical address of the application data is recorded in the reference data, it does not need to be recorded repeatedly in the reference address table. The actual needs can be met by identifying the reference data or recycling the reference.

[0097] 2. When the logical address of the application data is recorded in the local data (temporary variable), there is no need to manage this reference. As the local data is recycled, the reference relationship no longer exists.

[0098] 3. When the logical address of application data is recorded in the content of other application data (NVR, module global data, ASR or ADR, etc.), the logical address corresponding to the physical address of this content is written into the reference address table, that is, the reference address is recorded in the reference address table when establishing the reference relationship.

[0099] Based on the above embodiments, the method may further include:

[0100] When it is detected that the target variable cancels the reference to the target application data, only the logical address of the written target application data is cleared in the physical address of the target variable.

[0101] In this optional implementation, when the logical address of application data is cleared in other data content, the application data is called garbage data, and there is no need to clear the reference address in the reference address table. When the application calls the system interface provided by RTE to apply for garbage collection or the application is deleted, the embedded operating system identifies the garbage data based on the reference address table and recycles the garbage data.

[0102] In this optional implementation, what is recorded in the reference address table is the reference address rather than the logical address of the application data. Furthermore, when the logical address of the target application data written is cleared in the physical address of the target variable, even if the content recorded in the reference address table is not cleared, it will not cause incorrect reference to the application data. Therefore, there is no need to synchronously modify the application data reference counter or the content in the reference address table when the reference relationship is cleared, and the execution efficiency of the application is not affected.

[0103] Figure 3 A flowchart of a garbage collection method provided in an embodiment of the present invention. This embodiment can be applied to the situation where garbage collection operations are performed on various garbage data in a target application based on the contents recorded in an application address table. The method can be executed by a garbage collection device, which can be implemented in the form of hardware and / or software, and can generally be configured in a restricted device (for example, various security elements or smart cards, etc.) installed with an embedded operating system, and executed by the runtime environment in the embedded operating system installed in the restricted device.

[0104] Correspondingly, such as Figure 3 As shown, the method may include:

[0105] S310: When it is detected that a garbage collection condition for a target application is met, obtain various application data created during the execution of the target application.

[0106] The target application may initiate a garbage collection application by calling a garbage collection interface provided by the runtime environment.

[0107] When the runtime environment receives the garbage collection request, it can directly execute the garbage collection operation for the target application. Alternatively, the runtime environment can cache the garbage collection request first and execute the garbage collection operation for the target application before subsequently executing a new processing task (typically, an operating system instruction processing task).

[0108] Optionally, the target application may trigger the initiation of the garbage collection application when it is deselected.

[0109] Accordingly, when it is detected that the target application initiates the garbage collection application, it can be determined that the garbage collection condition for the target application is met;

[0110] Alternatively, when it is detected that the target application has issued a garbage collection request, the garbage collection request may be cached, and when it is detected that a new processing task needs to be executed, it may be determined whether the garbage collection conditions for the target application are met, etc. This embodiment does not limit this.

[0111] In an optional implementation of this embodiment, obtaining each application data created during the execution of the target application may include:

[0112] According to the cached garbage collection application, an application data table matching the target application is obtained, and by querying the content recorded in the application data table, various application data created during the execution of the target application are obtained.

[0113] In this optional implementation, the target application may record information on each application data generated during execution in an application data table uniquely corresponding to the target application. By querying the application data table, the application data created by the target application during execution may be obtained.

[0114] Correspondingly, by parsing the garbage collection application, the application identifier of the target application can be obtained, and based on the application identifier, an application data table matching the target application can be indexed and obtained.

[0115] In another optional implementation of this embodiment, obtaining each application data created during the execution of the target application further includes:

[0116] According to the cached garbage collection application, obtaining a target storage area matching the target application in a preset divided user storage area;

[0117] Based on a preset data storage rule, each application data created during the execution of the target application is searched and obtained in the target storage area.

[0118] In a specific example, data corresponding to each application module can be stored in the pre-divided user storage area in the order of application module 1, application module 2, ..., application module n. When storing data corresponding to a certain application module, various types of application data are stored in sequence in the order of module assembly, module data set, application data set of application 1, application data set of application 2, ..., application data set of application n.

[0119] Furthermore, after obtaining the application identifier of the target application and the module identifier of the application module to which the target application belongs, the storage area corresponding to the application data of the target application can be located in the user storage area, and in the located storage area, the application data created by the target application during the execution process can be obtained.

[0120] S320: Identify junk data in each application data according to the reference address table and the reference data corresponding to the target application.

[0121] The reference address table is maintained by the reference management method for application data as described in any one of the embodiments of the present invention.

[0122] As mentioned above, an application has corresponding reference data, for example, the reference data corresponding to the application identifier (AID) of the application can be obtained by indexing the application identifier. Further, the reference data (or reference array) corresponding to the target application can be obtained.

[0123] As mentioned above, whether an application data is junk data can be determined by whether the application data is referenced. If the application data is referenced, the application data is in an active state, and if the application data is not referenced, the application data is junk data.

[0124] In the prior art, whether an application data is referenced is mainly determined by whether its logical address is recorded in the reference data, which has a high probability of misjudging the application data that is still active as junk data. Based on this, the embodiments of the present invention mainly combine the reference addresses recorded in the reference address table to accurately determine whether an application data is junk data when the logical address of the application data is not recorded in the reference data.

[0125] It can be understood that if the logical address of an application data A is recorded in the matching reference data, it can be said that the application data A is definitely not junk data; if the logical address of the application data A is not recorded in the matching reference data, it can continue to be searched in the reference address table;

[0126] By searching the reference address table, there may be two results: one is that the application data A is referenced by other application data (or variables), and the other is that the application data A is not referenced by other application data.

[0127] If the application data A is not referenced by other application data, it can be directly determined that the application data A is garbage data. If the application data A is referenced by other application data, it cannot be directly determined that the application data A is not garbage data. Because if the other application data that references the application data A is garbage data, this reference relationship cannot be established, and the application data A still needs to be recycled as garbage data. Only when the other application data that references the application data A is not garbage data, can it be determined that the application data A is not garbage data.

[0128] The method of determining whether the other application data is junk data is the same as the method of determining whether the application data A is junk data. It is also necessary to make a joint judgment based on the reference address table and the reference data corresponding to the target application. Therefore, it may be necessary to use a multi-level identification method to determine whether the application data A is junk data.

[0129] S330: Execute a garbage collection operation according to the identified garbage data.

[0130] After the junk data is identified, the junk data can be deleted from the memory and the corresponding memory space can be released. In addition, if the reference address related to the junk data is recorded in the reference address table, the related reference address needs to be cleared from the reference address table simultaneously.

[0131] Correspondingly, the garbage collection operation includes an update operation on the reference address table, and the update operation is to delete the reference address related to the garbage data from the reference address table.

[0132] The technical solution of the embodiment of the present invention is to obtain the application data created by the target application during the execution process when it is detected that the garbage collection conditions for the target application are met; identify the garbage data in the application data according to the reference address table and the reference data corresponding to the target application; and perform garbage collection operations according to the identified garbage data. The reference address table is used to manage all application data references that are not recorded in the reference data, so as to avoid mistaking such application data for garbage data and deleting them, thereby avoiding null exceptions caused by referencing non-existent application data. In addition, when the application applies for garbage collection or is deleted, the operating system can identify whether the application data is garbage data according to the reference address table, thereby avoiding setting a garbage data flag in the application data, thereby avoiding excessive erasing of the memory and improving garbage collection performance.

[0133] On the basis of the above embodiments, identifying junk data in the application data according to the reference address table and the reference data corresponding to the target application may include:

[0134] When the logical address of the application data is not recorded in the reference data corresponding to the target application program, and the reference address table does not contain the reference address that references the application data, the application data is determined to be garbage data, or;

[0135] When the logical address of the application data is not recorded in the reference data corresponding to the target application, and the logical addresses of the referrer data that references the application data extracted level by level from the reference address table are not recorded in the reference data corresponding to the target application, the application data is determined to be garbage data.

[0136] As mentioned above, only when the logical address of only one application data is recorded in the reference data can it be determined that the application data is not junk data; and only when the logical address of only one application data is not recorded in the reference data and the reference address table does not contain the reference address that references the application data, can it be determined that the application data is junk data. Based on this, when any of the above conditions is detected, it can be determined that the end detection condition is met, and then, it can be judged whether the application data, or other data that references the application data step by step, is junk data.

[0137] It can be understood that if an application data is simultaneously referenced by an application data X confirmed as junk data and an application data Y confirmed as non-junk data, the application data is not junk data.

[0138] Figure 4 A flowchart of another garbage collection method provided for an embodiment of the present invention. This embodiment is optimized based on the techniques of the above-mentioned embodiments. In this embodiment, the operation of "identifying garbage data in the application data based on a reference address table and reference data corresponding to the target application" is concretized.

[0139] Correspondingly, such as Figure 4 As shown, the method may specifically include:

[0140] S410: When it is detected that a garbage collection condition for a target application is met, obtain application data created during the execution of the target application.

[0141] S420: Acquire currently processed application data, and acquire a logical address of the currently processed application data as a search logical address.

[0142] In this embodiment, a specific application data (ie, currently processed application data) among the obtained multiple application data is taken as an example to describe the process of determining whether the currently processed application data is junk data.

[0143] First, the logical address of the currently processed application data needs to be obtained as the search logical address.

[0144] S430. Search whether the search logic address is recorded in the reference data corresponding to the target application; if so, execute S440; otherwise, execute S450.

[0145] S440: Determine whether the currently processed application data is junk data.

[0146] If the search logic address is recorded in the reference data corresponding to the target application, it can be directly determined that the currently processed application data is not junk data; otherwise, it is necessary to perform subsequent judgment in conjunction with the reference address table.

[0147] S450, traverse and obtain each reference address in the reference address table, and obtain the comparison logical address of the referenced data recorded in each referencer data according to the logical address of the referencer data recorded in each reference address and the offset of the logical address of the referenced data in the referencer data.

[0148] In this embodiment, each reference address in the reference address table records the logical address of the referencer data and the offset of the logical address of the referenced data in the referencer data.

[0149] Based on the above two information, the logical address of the referenced data corresponding to each reference address is obtained. The above logical address obtained in this embodiment is determined as the comparison logical address of the referenced data.

[0150] S460. If it is determined that the comparison logical address corresponding to the target referrer data is the same as the search logical address, the logical address of the target referrer data is used as the new search logical address, and the iterative search in the reference address table is continued until all the target referrer data of the currently processed application data are identified step by step.

[0151] In this embodiment, if it is determined that the comparison logical address corresponding to the target referrer data is the same as the search logical address, it means that the currently processed application data is referenced by other application data, and it is necessary to continue to determine whether the referrer data is junk data.

[0152] In a specific example, application data A is the currently processed application data. By querying the reference address table, it is determined that application data A is referenced by application data B, and application data B is referenced by application data C. Then application data B and application data C are both target referrer data of application data A. The difference is that application data B directly references application data A, while application data C references application data A by referencing application data B.

[0153] When it can be directly determined that application data B or application data C is not junk data, it can be directly determined that application data A is not junk data. However, once it is determined that application data C is junk data, application data B is only referenced by application data C, and application data A is only referenced by application data B, then both application data A and application data B are junk data.

[0154] S470: When it is determined that the reference data corresponding to the target application does not record the logical address of any target referrer data, it is determined that the currently processed application data and each target referrer data are all garbage data.

[0155] The technical solution of the embodiment of the present invention adopts the technical means of jointly identifying the junk data in the application data according to the reference address table and the reference data corresponding to the target application, and uses the reference address table to manage all application data references that are not recorded in the reference data, which can avoid to the greatest extent the occurrence of such application data being mistakenly identified as junk data and deleted, thereby avoiding null exceptions caused by referencing non-existent application data, thereby improving the execution stability and reliability of the application in the runtime environment.

[0156] In order to further describe the technical solutions of various embodiments of the present invention, the technical solutions of various embodiments of the present invention are now described in detail from three dimensions: the process of establishing a reference, the process of canceling a reference, and the process of recycling garbage data.

[0157] 1. The process of establishing references

[0158] The reference process is the process of recording the logical address of application data during application programming, which facilitates the rapid retrieval of application data in business processes. The operation of recording application data is usually an assignment operation. Figure 5 A flowchart for implementing the reference establishment process is shown in FIG.

[0159] The specific steps of the above flowchart are as follows:

[0160] 1) The application allocates application data A by calling the system interface provided by RTE. After the system interface completes the creation of application data A, it gives the logical address of application data A as the return value to the application code and executes the subsequent code.

[0161] 2) The business code of the application program does not perform any record operation on the logical address of the application data A, and the application data A will not be referenced. At this time, the application data A is garbage data.

[0162] 3) If the logical address of application data A is assigned to local data, the logical address of application data A can be directly written into the physical address of local data. Since local data is allocated in the stack, the stack is popped and the local data is recycled. At this time, application data A becomes unreferenced garbage data. If the logical address of application data A is not assigned to local data, continue with the following process.

[0163] 4) If the logical address of application data A is assigned to the reference array (or reference data), the logical address of application data A is written into the reference array through the offset specified by the program code.

[0164] Among them, Figure 6 FIG. 2 shows a schematic diagram of a data reference relationship stored only by referencing data applicable to an application scenario of an embodiment of the present invention. Figure 6 As shown, Array 1 and Array 3 are both referenced by array references, while Array x is not referenced. By referencing the references constructed by the array record, you can identify whether the reference exists by querying the content of the data element in the reference array. If not, continue with the following process.

[0165] 5) If the logical address A of the application data is written into the module global data or another member of application data B, the logical address A of the application data is written into the physical address where the variable is located. At the same time, the logical address of the module global data or application data B and the offset where the variable is located are combined into a reference address and written into the reference address table.

[0166] Among them, Figure 7 A schematic diagram of storing application data reference relationships simultaneously through reference data and a reference address table applicable to the application scenario of an embodiment of the present invention is shown in FIG.

[0167] like Figure 7 As shown in the figure, Array 1 and Array 3 are referenced by the reference array, while Array 1_1, Array 1_2, Array 3_1, Array x_1, and Array x_2 ​​are not referenced by the reference array. However, they are recorded in the reference address table. The application data Array x is not referenced by the reference array or the reference address table, so Array x is considered garbage data.

[0168] Specifically, taking the reference address REF_ADDR_1 as an example, REF_ADDR_1 is composed of the logical address of the application data Array 1 and the offset of Array 1_1 in Array 1. Figure 8 A schematic diagram of storing a reference address through four-byte data applicable to the application scenario of an embodiment of the present invention is shown in FIG.

[0169] Among them, Figure 8 As shown, REF_FLAG identifies the four-byte data as a reference address, REF_ID represents the logical address of application data Array 1, and REF_OFFSET represents the offset of application data Array 1_1 in application data Array 1.

[0170] Furthermore, Fig. 9 A schematic diagram showing member data of application data A referencing application data B applicable to an application scenario of an embodiment of the present invention is shown in FIG.

[0171] like Fig. 9 As shown, when the member data in application data A references application data B, byte5-byte8 in application data A records the logical address of application data B.

[0172] When module global data references application data, it is necessary to write the logical address of application data A in the physical address where the module global data is located. At the same time, it is also necessary to form a reference address with the module identifier (ID) where the module global data is located and the offset of the module global data and write it into the reference address table.

[0173] 6) Furthermore, if the variable is not a member of the module global data or another application data B, the program code is wrong and an exception is thrown.

[0174] 2. The process of dereferencing

[0175] Dereference means that the content of the logical address recording the application data is cleared, and the Fig. 9 As shown, byte5-byte8 in application data A records the logical address of application data B. If byte5-byte8 are all written as 0, the reference is cleared.

[0176] Continue as Figure 7 As shown in the figure, Array x_1 is referenced by both Array x and Array3_1. If the content recording the logical address of Array x_1 in Array3_1 is cleared, only the reference of Array3_1 to Array x_1 is cancelled, and Array x_1 is still referenced by Array x, so Array x_1 is not garbage data at this time. If the garbage data Array x is recycled, Array x_1 will no longer be referenced and become garbage data. Therefore, an application data can be referenced by multiple other data, but the application data that references the application data itself is garbage data. This reference is considered invalid and is recycled together during garbage collection. In other words, through the reference relationship, the branches are searched upward according to each branch, and the branches that are not referenced by the reference array are finally considered garbage data.

[0177] 3. Garbage data collection process

[0178] The application requests garbage collection by calling the interface provided by RTE. At this time, the embedded operating system will not start garbage collection and space arrangement immediately. The system will start garbage collection and space arrangement after the current business session ends and before the next business session starts.

[0179] To identify whether an application data A is junk data, the steps are as follows:

[0180] 1) Check whether the logical address of the application data A is recorded in the reference array. If it exists, the data is not garbage data. If it does not exist, execute the subsequent process.

[0181] 2) Read the reference addresses one by one in the reference address table, and identify whether the application data or module global data belongs to the application currently applying for garbage collection through the reference address. If not, read the next one; if yes, execute the subsequent process.

[0182] 3) Read the application data logical address through the reference address and check whether it is the same as the logical address of the application data A. If they are the same, there is a reference. If they are different, go to step 2 to continue reading the reference address.

[0183] 4) The logical address corresponding to the reference address is used as a new application data to identify whether it is garbage data, and step 1) is executed.

[0184] 5) If the referenced array reference is found, the application data A is not junk data; if the referenced array reference is not found, the application data A is junk data.

[0185] 6) If all reference addresses are searched and no reference exists, the application data A is garbage data.

[0186] 7) After completing the garbage data identification, the operating system RTE recycles the garbage data.

[0187] The technical solution of this embodiment can achieve the following beneficial effects:

[0188] 1) All application data references in the unrecorded sub-reference array are managed through the reference address table to avoid mistaking such application data for garbage data and deleting it, thereby avoiding null exceptions caused by referencing non-existent application data.

[0189] 2) The reference address table records the reference address instead of the logical address of the application data, so as to avoid synchronously modifying the application data reference counter or the content in the reference address table when the reference relationship is cleared, without affecting the execution efficiency of the application.

[0190] 3) When an application applies for garbage collection or is deleted, the system identifies whether the application data is garbage data based on the reference address table, avoiding setting a garbage data flag in the application data, thereby avoiding excessive erasing of the FLASH and improving the recycling performance.

[0191] Fig.10 The present invention provides a schematic diagram of the structure of a device for managing the reference of application data, which is configured in a runtime environment of an embedded operating system installed in a restricted device. Fig.10 As shown, the device includes: a logical address writing module 1010 and a reference address writing module 1020, wherein:

[0192] The logical address writing module 1010 is used to write the logical address of the target application data into the physical address of the target variable when it is detected that the target application data is referenced by the target variable and the target variable belongs to the target variable type;

[0193] The reference address writing module 1020 is used to write the logical address corresponding to the physical address of the target variable into the reference address table as the reference address.

[0194] The technical solution of the embodiment of the present invention, through the technical means of writing the logical address of the target application data into the physical address of the target variable when it is detected that the target application data is referenced by the target variable and the target variable belongs to the target variable type; writing the logical address corresponding to the physical address of the target variable as the reference address into the reference address table, can use the reference address table to manage all application data references that are not recorded in the reference data, avoid such application data being mistaken for garbage data and being deleted, thereby avoiding null exceptions caused by referencing non-existent application data. In addition, the reference address table records the reference address instead of the logical address of the application data, avoids the need to synchronously modify the application data reference counter or the content in the reference address table when the reference relationship is cleared, and ensures the execution efficiency of the application to a certain extent.

[0195] Based on the above embodiments, the logic address writing module 1010 can be used to:

[0196] When the logical address of the target application data is assigned to the target variable, it is determined that it is detected that the target application data is referenced by the target variable.

[0197] Based on the above embodiments, the target variable types may include: persistent data, module global data, temporary static variable data, and temporary dynamic variable data.

[0198] Based on the above embodiments, the reference address writing module 1020 can be specifically used for:

[0199] According to the physical address of the target variable, acquiring the logical address of the target variable and the offset of the logical address of the target application data in the target variable;

[0200] The logical address of the target variable and the offset of the logical address of the target application data in the target variable are combined to obtain a reference address, and the combined reference address is written into a reference address table.

[0201] Based on the above embodiments, in the reference address table, each reference address is represented by four bytes of data with an identifier;

[0202] The identifier is used to indicate that the four-byte data is a reference address, the first two bytes of the four-byte data are used to store the logical address of the referencer data, and the last two bytes of the four-byte data are used to store the offset of the logical address of the referenced data in the referencer data.

[0203] Based on the above embodiments, the reference address table is stored in the non-volatile storage space of the restricted device.

[0204] Based on the above embodiments, the method may further include: a first reference processing module, which is used to:

[0205] When it is detected that the target application data is referenced by the target variable and the target variable belongs to the referenced data, only the logical address of the target application data is written into the physical address of the target variable.

[0206] Based on the above embodiments, the present invention may further include: a second reference processing module, which is used to:

[0207] When it is detected that the target application data is referenced by the target variable and the target variable belongs to local data, only the logical address of the target application data is written into the physical address of the target variable.

[0208] Based on the above embodiments, the present invention may further include a reference clearing module, which is used to:

[0209] When it is detected that the target variable cancels the reference to the target application data, only the logical address of the written target application data is cleared in the physical address of the target variable.

[0210] The application data reference management device provided in the embodiment of the present invention can execute the application data reference management method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0211] Fig.11The present invention provides a schematic diagram of the structure of a garbage collection device, which is configured in a runtime environment of an embedded operating system installed in a restricted device. Fig.11 As shown, the device includes: an application data acquisition module 1110, a garbage data identification module 1120 and a garbage collection processing module 1130, wherein:

[0212] The application data acquisition module 1110 is used to acquire various application data created by the target application during execution when it is detected that the garbage collection condition for the target application is met;

[0213] A garbage data identification module 1120, configured to identify garbage data in each application data according to a reference address table and reference data corresponding to the target application;

[0214] Wherein, the reference address table is maintained by the reference management method for application data as described in any embodiment of the present invention;

[0215] The garbage collection processing module 1130 is used to perform garbage collection operations according to the identified garbage data.

[0216] The technical solution of the embodiment of the present invention is to obtain the application data created by the target application during the execution process when it is detected that the garbage collection conditions for the target application are met; identify the garbage data in the application data according to the reference address table and the reference data corresponding to the target application; and perform garbage collection operations according to the identified garbage data. The reference address table is used to manage all application data references that are not recorded in the reference data, so as to avoid mistaking such application data for garbage data and deleting them, thereby avoiding null exceptions caused by referencing non-existent application data. In addition, when the application applies for garbage collection or is deleted, the operating system can identify whether the application data is garbage data according to the reference address table, thereby avoiding setting a garbage data flag in the application data, thereby avoiding excessive erasing of the memory and improving garbage collection performance.

[0217] Based on the above embodiments, the application data acquisition module 1110 can be specifically used for:

[0218] When it is detected that the target application program issues a garbage collection request, the garbage collection request is cached, and when it is detected that a new processing task needs to be executed, it is determined that the garbage collection condition for the target application program is satisfied.

[0219] Based on the above embodiments, the application data acquisition module 1110 can be further specifically used for:

[0220] According to the cached garbage collection application, an application data table matching the target application is obtained, and by querying the content recorded in the application data table, various application data created during the execution of the target application are obtained.

[0221] Based on the above embodiments, the application data acquisition module 1110 can be further specifically used for:

[0222] According to the cached garbage collection application, obtaining a target storage area matching the target application in a preset divided user storage area;

[0223] Based on a preset data storage rule, each application data created during the execution of the target application is searched and obtained in the target storage area.

[0224] Based on the above embodiments, the junk data identification module 1120 can be specifically used for:

[0225] When the logical address of the application data is not recorded in the reference data corresponding to the target application program, and the reference address table does not contain the reference address that references the application data, the application data is determined to be garbage data, or;

[0226] When the logical address of the application data is not recorded in the reference data corresponding to the target application, and the logical addresses of the referrer data that references the application data extracted level by level from the reference address table are not recorded in the reference data corresponding to the target application, the application data is determined to be garbage data.

[0227] Based on the above embodiments, the junk data identification module 1120 can be further specifically used for:

[0228] Acquire the currently processed application data, and acquire the logical address of the currently processed application data as the search logical address;

[0229] In the reference data corresponding to the target application, searching whether the search logic address is recorded;

[0230] If not, traverse and obtain each reference address in the reference address table, and obtain the comparison logical address of the referenced data recorded in each reference data according to the logical address of the referencer data recorded in each reference address and the offset of the logical address of the referenced data in the referencer data;

[0231] If it is determined that the comparison logical address corresponding to the target referrer data is the same as the search logical address, the logical address of the target referrer data is used as a new search logical address, and the search is continued iteratively in the reference address table until all the target referrer data of the currently processed application data are identified level by level;

[0232] When it is determined that the logical address of any target referrer data is not recorded in the reference data corresponding to the target application, it is determined that the currently processed application data and each target referrer data are all garbage data.

[0233] The garbage collection device provided in the embodiment of the present invention can execute the garbage collection method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0234] In the technical solution of the present disclosure, the collection, storage, use, processing, transmission, provision and disclosure of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.

[0235] Fig.12 A schematic diagram of the structure of a restricted device 10 that can be used to implement an embodiment of the present invention is shown.

[0236] like Fig.12 As shown, the limited device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by the at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the limited device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.

[0237] The I / O interface 15 in the restricted device 10 may include: eSPI (Enhanced Serial Peripheral Interface) and SPI (Serial Peripheral Interface), etc.

[0238] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The processor 11 executes the various methods and processes described above, for example, executing a reference management method for application data as described in various embodiments of the present invention, which is executed by a runtime environment in an embedded operating system, and the embedded operating system is installed in a restricted device, and the method includes:

[0239] When it is detected that the target application data is referenced by the target variable and the target variable belongs to the target variable type, writing the logical address of the target application data into the physical address of the target variable;

[0240] The logical address corresponding to the physical address of the target variable is written as the reference address into the reference address table.

[0241] Alternatively, a garbage collection method as described in various embodiments of the present invention is executed by a runtime environment in an embedded operating system, where the embedded operating system is installed in a restricted device, and the method includes:

[0242] When it is detected that a garbage collection condition for the target application is met, obtaining each application data created during the execution of the target application;

[0243] Identifying junk data in each application data according to the reference address table and the reference data corresponding to the target application;

[0244] Wherein, the reference address table is maintained by the reference management method for application data as described in any one of the embodiments of the present invention;

[0245] Perform garbage collection operations based on the identified garbage data.

[0246] In some embodiments, a reference management or garbage collection method for application data as described in various embodiments of the present invention may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 16. In some embodiments, part or all of the computer program may be loaded and / or installed on the restricted device 10 via the ROM 12. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the reference management or garbage collection method for application data as described in various embodiments of the present invention described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to perform a reference management or garbage collection method for application data as described in various embodiments of the present invention in any other appropriate manner (for example, by means of firmware).

[0247] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0248] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0249] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer 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 of the foregoing.

[0250] Fig.13 is a structural diagram of a terminal provided according to an embodiment of the present invention. Fig.13 Said terminal includes the restricted device 1310 as described in any embodiment of the present invention.

[0251] The limited device can be understood as a resource-limited device. A resource-limited device can be understood as an electronic device with limited storage capacity, whose RAM resources are limited, generally a few KB to tens of KB, and NVM (non-volatile memory) resources ( Fig.12 Taking ROM as an example) it is tens of KB to hundreds of KB, and the maximum is MB level.

[0252] The resource-constrained device may generally be: a smart card, a USBKEY, an ESAM (Embedded Secure Access Module) or an SE (Secure Element), etc. The smart card may generally be a multi-application smart card.

[0253] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.

Claims

1. A method for managing references of application data, characterized in that: The method is executed by a runtime environment in an embedded operating system installed in a restricted device, and includes: When it is detected that the target application data is referenced by the target variable and the target variable belongs to the target variable type, writing the logical address of the target application data into the physical address of the target variable; The logical address corresponding to the physical address of the target variable is written into the reference address table as a reference address, wherein the target application data is generated during the execution of the target application program running in the logical channel.

2. The method according to claim 1, characterized in that: Detect that the target application data is referenced by the target variable, including: When the logical address of the target application data is assigned to the target variable, it is determined that it is detected that the target application data is referenced by the target variable.

3. The method according to claim 1, characterized in that The target variable types include: persistent data, module global data, temporary static variable data and temporary dynamic variable data.

4. The method according to claim 1, characterized in that: The logical address corresponding to the physical address of the target variable is written as the reference address into the reference address table, including: According to the physical address of the target variable, acquiring the logical address of the target variable and the offset of the logical address of the target application data in the target variable; The logical address of the target variable and the offset of the logical address of the target application data in the target variable are combined to obtain a reference address, and the combined reference address is written into a reference address table.

5. The method according to claim 4, characterized in that In the reference address table, each reference address is represented by four bytes of data with an identifier; The identifier is used to indicate that the four-byte data is a reference address, the first two bytes of the four-byte data are used to store the logical address of the referencer data, and the last two bytes of the four-byte data are used to store the offset of the logical address of the referenced data in the referencer data.

6. The method according to claim 1, characterized in that The reference address table is stored in a non-volatile storage space of the restricted device.

7. A garbage collection method, characterized in that: The method is executed by a runtime environment in an embedded operating system installed in a restricted device, and includes: When it is detected that a garbage collection condition for the target application is met, obtaining each application data created during the execution of the target application; Identifying junk data in each application data according to the reference address table and the reference data corresponding to the target application; Wherein, the reference address table is maintained by the reference management method for application data according to any one of claims 1 to 6; A garbage collection operation is performed according to the identified garbage data, wherein the garbage collection operation includes an update operation on the reference address table.

8. The method according to claim 7, characterized in that Detects that conditions for garbage collection are met for the target application, including: When it is detected that the target application program issues a garbage collection request, the garbage collection request is cached, and when it is detected that a new processing task needs to be executed, it is determined that the garbage collection condition for the target application program is satisfied.

9. The method according to claim 8, characterized in that Get the application data created by the target application during execution, including: According to the cached garbage collection application, an application data table matching the target application is obtained, and by querying the content recorded in the application data table, various application data created during the execution of the target application are obtained.

10. The method according to claim 8, characterized in that Get the application data created by the target application during execution, including: According to the cached garbage collection application, obtaining a target storage area matching the target application in a preset divided user storage area; Based on a preset data storage rule, each application data created during the execution of the target application is searched and obtained in the target storage area.

Citation Information

Patent Citations

  • Storage equipment and junk data recovery method thereof

    CN105701024A

  • Storage space recovery method and device

    CN110399310A

  • Method and device for managing memory, resource-constrained device and storage medium

    CN116820785A

  • Storage control apparatus and storage control program medium

    US20180203637A1