Character string processing method and device, program product and storage medium

By multiplexing the target read-only constant data from the read-only constant area in JSON data processing, the memory inefficiency problem caused by repeated string storage is solved, and efficient memory usage is achieved.

CN120371309APending Publication Date: 2025-07-25ZHEJIANG DAHUA TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510362004.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-25
Publication Date
2025-07-25

AI Technical Summary

Technical Problem

In JSON data processing, repeated storage of strings leads to inefficient memory usage, especially in process memory.

Method used

During the process of running the executable file, the string address is found from the read-only constant area and the matching target read-only constant data is used to process the string to avoid repeated memory allocation.

Benefits of technology

It reduces the total memory footprint, avoids frequent memory allocation and release operations, and improves memory usage efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120371309A_ABST
    Figure CN120371309A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a character string processing method and device, a program product and a storage medium, and the method comprises the steps: obtaining a first character string address of a to-be-executed first character string in an executable file in a process of running the executable file of target structured data; the first character string address is searched in the address range of a read-only constant area, the read-only constant area is N pieces of read-only constant data, the numerical values of the N pieces of read-only constant data are determined when the executable file is used for storing and compiling the target structured data, and N is a natural number larger than or equal to 1; and under the condition that the first character string address is within the address range, multiplexing target read-only constant data matched with the first character string from the N read-only constant data to indicate the executable file to process the first character string based on the target read-only constant data. Through the method and the device, the problem of high resource consumption of character string processing in related technologies is solved, and the effect of reducing resource consumption of character strings is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of computer technology. Specifically, the embodiments of the present application relate to a method and apparatus for processing strings, a program product, and a storage medium. Background Art

[0002] JavaScript Object Notation (JSON) is a lightweight data interchange format. With its concise syntax and easy-to-read characteristics for humans, JSON has become the mainstream choice in the field of front-end and back-end data interaction and data storage. The JSON data structure expresses attributes and values in the form of key-value (i.e., key-value pairs). Among them, the key (i.e., the key) always appears in the form of a string, while the value (i.e., the key value) can be a string, a number, a boolean value, an array, an object, or null. In JSON data, strings are one of the most common data types, not only serving as the identifier of the key but also often appearing as the value, especially when text information or identifiers need to be stored.

[0003] In modern software development, the processing of JSON data often involves dynamic generation and parsing. To adapt to different data requirements and scenarios, a large amount of JSON data needs to be dynamically created and modified. However, the management of strings in this process has become a bottleneck in memory optimization. The storage of strings in the process memory, especially repeatedly occurring strings, will occupy a large amount of memory space. Although the compression encoding of JSON data can reduce the volume of data transmission, in the process memory, the repeated storage of strings still leads to low memory usage efficiency. Summary of the Invention

[0004] The embodiments of the present application provide a method and apparatus for processing strings, a program product, and a storage medium, so as to at least solve the problem of high resource consumption in processing strings in related technologies.

[0005] According to an embodiment of the present application, a method for processing a string is provided, including: during the process of running an executable file of target structured data, obtaining a first string address of a first string to be executed in the executable file, where the target structured data is structured data for implementing a target task; searching for the first string address from an address range of a read-only constant area, where the read-only constant area is N read-only constant data for storing determined values during compilation of the target structured data in the executable file, and N is a natural number greater than or equal to 1; in the case where the first string address is within the address range, reusing a target read-only constant data that matches the first string from the N read-only constant data to instruct the executable file to process the first string based on the target read-only constant data.

[0006] In an exemplary embodiment, before obtaining the first string address of the first string to be executed in the executable file during the process of running the executable file of the target structured data, the method further includes: when running the executable file, parsing address information in the executable file to determine the address range of the read-only constant area; based on the address range of the read-only constant area, reading M original read-only constant data included in the read-only constant area; removing invisible characters in the M original read-only constant data to obtain N read-only constant data, where the invisible characters are used to represent non-text characters; setting initial reference information for each read-only constant data, where the initial reference information for each read-only constant data is used to represent the number of times the string in each read-only constant data is initially referenced.

[0007] In an exemplary embodiment, in the case where the first string address is within the address range, reusing a target read-only constant data that matches the first string from the N read-only constant data to instruct the executable file to process the first string based on the target read-only constant data includes: in the case where the first string address is within the address range, obtaining a target string in the target read-only constant data according to the first string address, where the address of the target string is the same as the first string address; running the executable file based on the target string to reuse the target read-only constant data.

[0008] In an exemplary embodiment, after running the executable file based on the above target string to reuse the above target read-only constant data, the method further includes: updating the reference information of the above target read-only constant data during the running of the executable file to obtain the first target reference information of the above target read-only constant data, where the reference information of the above target read-only constant data is used to represent the number of times the target string in the above target read-only constant data is referenced; updating the above first target reference information when the life cycle of the above target string is a first preset threshold.

[0009] In an exemplary embodiment, after searching for the above first string address from the address range of the above read-only constant area, the method further includes: when the above first string address is not within the above address range, searching for the above target read-only constant data from N pieces of the above read-only constant data according to the above first string, where the target string in the above target read-only constant data is the same as the above first string; when the above target string is the constant data in N pieces of the above read-only constant data, running the executable file based on the above target string and updating the reference information of the above target read-only constant data to obtain the second target reference information of the above target read-only constant data, where the reference information of the above target read-only constant data is used to represent the number of times the target string in the above target read-only constant data is referenced.

[0010] In an exemplary embodiment, after searching for the above first string address from the address range of the above read-only constant area, the method further includes: when the above first string address is not within the above address range and the target string in the above target read-only constant data is not included in N pieces of the above read-only constant data, searching for the above target read-only constant data from a first read-only constant set according to the above first string, where the above target string is the same as the above first string, the first read-only constant set includes a plurality of first read-only constant data and the reference information of each piece of the above first read-only constant data, and the reference information of the above first read-only constant data is used to represent the number of times the string in each piece of the above first read-only constant data is referenced; when the above target string is included in the above first read-only constant set, running the executable file based on the above target string and updating the reference information of the above target read-only constant data in the above first read-only constant set to obtain the third target reference information of the above target read-only constant data; updating the above third target reference information when the life cycle of the above target string is a second preset threshold; when the updated third target reference information is a target threshold, deleting the above target read-only constant data from the above first read-only constant set and releasing the storage space of the above target string.

[0011] In an exemplary embodiment, when the above first string address is outside the above address range and the target string in the target read-only constant data is not in the above first read-only constant set, after finding the above target read-only constant data in the second read-only constant set according to the above first string, the method further includes: when the above first string is not included in the above first read-only constant set, applying for a first storage space to store the above first string in the above first storage space to obtain the string of the first target read-only constant data; running the above executable file based on the string of the first target read-only constant data; adding the above first target read-only constant data to the above first read-only constant set, and setting the initial reference information of the above first target read-only constant data, where the initial reference information of the above first target read-only constant data is used to represent the number of times the first string in each of the above first target read-only constant data is initially referenced.

[0012] In an exemplary embodiment, when the above first string address is within the above address range, after reusing the target read-only constant data that matches the above first string from N pieces of the above read-only constant data to instruct the above executable file to process the above first string based on the above target read-only constant data, the method further includes: during the process of running the above executable file, obtaining the storage space usage information of the above executable file; calculating the storage space utilization rate of the above executable file based on the above storage space usage information and the storage space information of the target device; when the above storage space utilization rate is greater than a preset usage threshold, obtaining the first log information and the second log information of the above executable file, where the above first log information includes the read-only constant data among N pieces of the above read-only constant data whose reference information is greater than a third preset threshold, the above second log information includes multiple first read-only constant data in the first read-only constant set and the reference information of each of the above first read-only constant data, the reference information of the read-only constant data is used to represent the number of times the string in each of the above read-only constant data is referenced, and the reference information of the above first read-only constant data is used to represent the number of times the string in each of the above first read-only constant data is referenced; determining the abnormal read-only constant data among N pieces of the above read-only constant data and the above first read-only constant set based on the reference information of the read-only constant data among N pieces of the above read-only constant data whose reference information is greater than the above third preset threshold and the reference information of the above first read-only constant data, where the above abnormal read-only constant data is the constant data that abnormally occupies the storage space.

[0013] According to an embodiment of the present application, a processing device for a string is provided, including: a first acquisition module, configured to acquire a first string address of a first string to be executed in the executable file during the process of running the executable file of the target structured data, where the target structured data is structured data for implementing a target task; a first search module, configured to search for the first string address from the address range of the read-only constant area, where the read-only constant area is N read-only constant data for storing determined values during the compilation of the target structured data in the executable file, and N is a natural number greater than or equal to 1; a first processing module, configured to, when the first string address is within the address range, reuse a target read-only constant data that matches the first string from the N read-only constant data, so as to instruct the executable file to process the first string based on the target read-only constant data.

[0014] In an exemplary embodiment, the device further includes: a first parsing module, configured to parse the address information in the executable file during the process of running the executable file to determine the address range of the read-only constant area before acquiring the first string address of the first string to be executed in the executable file during the process of running the executable file of the target structured data; a first reading module, configured to read M original read-only constant data included in the read-only constant area based on the address range of the read-only constant area; a first removing module, configured to remove invisible characters in the M original read-only constant data to obtain the N read-only constant data, where the invisible characters are used to represent non-text characters; a first setting module, configured to set initial reference information for each of the read-only constant data, where the initial reference information for each of the read-only constant data is used to represent the number of times the string in each of the read-only constant data is initially referenced.

[0015] In an exemplary embodiment, the first processing module includes: a first acquisition sub-module, configured to, when the first string address is within the address range, acquire a target string in the target read-only constant data according to the first string address, where the address of the target string is the same as the first string address; a first reuse sub-module, configured to run the executable file based on the target string to reuse the target read-only constant data.

[0016] In an exemplary embodiment, the first processing module further includes: a first update sub-module, configured to run the executable file based on the target string, and after reusing the target read-only constant data, update the reference information of the target read-only constant data during the running of the executable file to obtain first target reference information of the target read-only constant data, where the reference information of the target read-only constant data is used to represent the number of times the target string in the target read-only constant data is referenced; a second update sub-module, configured to update the first target reference information when the life cycle of the target string reaches a first preset threshold.

[0017] In an exemplary embodiment, the apparatus further includes a second search module, configured to search for the first string address from the address range of the read-only constant area, and when the first string address is not within the address range, search for the target read-only constant data from N pieces of the read-only constant data according to the first string, where the target string in the target read-only constant data is the same as the first string; a first running module, configured to run the executable file based on the target string when the target string is a constant data among N pieces of the read-only constant data, and update the reference information of the target read-only constant data to obtain second target reference information of the target read-only constant data, where the reference information of the target read-only constant data is used to represent the number of times the target string in the target read-only constant data is referenced.

[0018] In an exemplary embodiment, the above-mentioned device further includes a third search module, configured to search for the above-mentioned first string address from the address range of the above-mentioned read-only constant area. After that, when the above-mentioned first string address is not within the above-mentioned address range and the target string in the above-mentioned target read-only constant data is not included in the N above-mentioned read-only constant data, the above-mentioned target read-only constant data is searched in the first read-only constant set according to the above-mentioned first string, where the above-mentioned target string is the same as the above-mentioned first string, the above-mentioned first read-only constant set includes a plurality of first read-only constant data and reference information of each above-mentioned first read-only constant data, and the reference information of the above-mentioned first read-only constant data is used to represent the number of times the string in each above-mentioned first read-only constant data is referenced; a second operation module, configured to, when the above-mentioned target string is included in the above-mentioned first read-only constant set, run the above-mentioned executable file based on the above-mentioned target string, and update the reference information of the above-mentioned target read-only constant data in the above-mentioned first read-only constant set to obtain the third target reference information of the above-mentioned target read-only constant data; a third update module, configured to update the above-mentioned third target reference information when the life cycle of the above-mentioned target string is a second preset threshold; a first release module, configured to, when the updated third target reference information is a target threshold, delete the above-mentioned target read-only constant data from the above-mentioned first read-only constant set and release the storage space of the above-mentioned target string.

[0019] In an exemplary embodiment, the above-mentioned device further includes: a first storage module, configured to, when the above-mentioned first string address is outside the above-mentioned address range and the target string in the above-mentioned target read-only constant data is not in the above-mentioned first read-only constant set, search for the above-mentioned target read-only constant data in the second read-only constant set according to the above-mentioned first string. After that, when the above-mentioned first string is not included in the above-mentioned first read-only constant set, apply for a first storage space to store the above-mentioned first string in the above-mentioned first storage space to obtain the string of the first target read-only constant data; a second operation module, configured to run the above-mentioned executable file based on the string of the above-mentioned first target read-only constant data; a first addition module, configured to add the above-mentioned first target read-only constant data to the above-mentioned first read-only constant set and set the initial reference information of the above-mentioned first target read-only constant data, where the initial reference information of the above-mentioned first target read-only constant data is used to represent the number of times the first string in each above-mentioned first target read-only constant data is initially referenced.

[0020] In an exemplary embodiment, the above device further includes: when the above first string address is within the above address range, reusing, from N pieces of the above read-only constant data, the target read-only constant data that matches the above first string, to instruct the above executable file to process the above first string based on the above target read-only constant data. After that, the method further includes: a second acquisition module, configured to acquire, during the running of the above executable file, the storage space usage information of the above executable file; a first calculation module, configured to calculate the storage space utilization rate of the above executable file based on the above storage space usage information and the storage space information of the target device; a third acquisition module, configured to, when the above storage space utilization rate is greater than a preset usage threshold, acquire the first log information and the second log information of the above executable file, where the above first log information includes the read-only constant data among the N pieces of the above read-only constant data whose reference information is greater than a third preset threshold, the above second log information includes multiple first read-only constant data in a first read-only constant set and the reference information of each of the above first read-only constant data, the reference information of the read-only constant data is used to represent the number of times the string in each of the above read-only constant data is referenced, and the reference information of the above first read-only constant data is used to represent the number of times the string in each of the above first read-only constant data is referenced; a first determination module, configured to determine, based on the reference information of the read-only constant data among the N pieces of the above read-only constant data whose reference information is greater than the above third preset threshold, and the reference information of the above first read-only constant data, the abnormal read-only constant data among the N pieces of the above read-only constant data and the above first read-only constant set, where the above abnormal read-only constant data is the constant data that abnormally occupies the storage space.

[0021] According to another embodiment of the present application, there is also provided a computer program product, including a computer program, where the above computer program is configured to be executed by a processor to perform the steps in any one of the above method embodiments.

[0022] According to another embodiment of the present application, there is also provided a computer-readable storage medium, in which a computer program is stored, where the above computer program is configured to be executed by a processor to perform the steps in any one of the above method embodiments.

[0023] According to another embodiment of the present application, there is also provided an electronic device, including a memory, a processor, and a computer program stored on the above memory and executable on the above processor, where the above processor is configured to execute the above computer program to perform the steps in any one of the above method embodiments.

[0024] Through this application, during the process of running an executable file, when a first string needs to be used, by looking up the address of the first string, if it is found that the address of this string is within the address range of the read-only constant area, this means that the string has already been placed in the read-only constant area, and there is no need to allocate memory again for storage. Instead, the target read-only constant data that matches the first string can be directly reused, avoiding repeated memory allocation for the same string during runtime. This not only reduces the total occupied space of memory but also avoids frequent memory allocation and release operations. Therefore, the problem of high consumption of string resources in the related art is solved, and the effect of reducing string resource consumption is achieved. Description of the Drawings

[0025] Figure 1 is a hardware structure block diagram of a mobile terminal for a method of processing strings according to an embodiment of the present application;

[0026] Figure 2 is a flowchart of a method of processing strings according to an embodiment of the present application;

[0027] Figure 3 is a flowchart of a method for compressing and processing strings in a specific embodiment of the present application;

[0028] Figure 4 is a flowchart of a method for releasing and processing strings in a specific embodiment of the present application;

[0029] Figure 5 is a flowchart of a method for locating and processing strings in a specific embodiment of the present application;

[0030] Figure 6 is a structure block diagram of a device for processing strings according to an embodiment of the present application. Detailed Embodiments

[0031] In the following, embodiments of the present application will be described in detail with reference to the drawings and in conjunction with the embodiments.

[0032] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects and do not necessarily need to be used to describe a specific order or sequence.

[0033] The method embodiments provided in the embodiments of the present application can be executed on a mobile terminal, a computer terminal, or a similar computing device. Taking running on a mobile terminal as an example, Figure 1 is a hardware structure block diagram of a mobile terminal for a method of processing strings according to an embodiment of the present application. As Figure 1 shown, the mobile terminal may include one or more ( Figure 1Only one processor 102 is shown (the processor 102 may include, but is not limited to, a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data. Among them, the above mobile terminal may further include a transmission device 106 for communication functions and an input / output device 108. Those of ordinary skill in the art can understand that Figure 1 The structure shown is only illustrative and does not limit the structure of the above mobile terminal. For example, the mobile terminal may further include more or fewer components than those Figure 1 shown, or have a different configuration from that Figure 1 shown.

[0034] The memory 104 can be used to store computer programs. For example, software programs and modules of application software, such as the computer program corresponding to a method for processing a string in an embodiment of the present application. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, implements the above method. The memory 104 may include a high-speed random access memory and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memories. In some instances, the memory 104 may further include a memory remotely provided with respect to the processor 102, and these remote memories can be connected to the mobile terminal through a network. Examples of the above network include, but are not limited to, the Internet, an enterprise intranet, a local area network, a mobile communication network, and combinations thereof.

[0035] The transmission device 106 is used to receive or send data via a network. Specific examples of the above network may include a wireless network provided by a communication provider of the mobile terminal. In one instance, the transmission device 106 includes a network adapter (abbreviated as NIC), which can be connected to other network devices through a base station and thus can communicate with the Internet. In one instance, the transmission device 106 may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0036] In this embodiment, a method for processing a string is provided. Figure 2 is a flowchart of a method for processing a string according to an embodiment of the present application, as Figure 2 shown, and the process includes the following steps:

[0037] Step S202, during the process of running the executable file of the target structured data, obtain the first string address of the first string to be executed in the executable file, where the above target structured data is structured data for implementing a target task;

[0038] Optionally, the target structured data can be JSON data. The generation of JSON data generally involves defining key-value pairs in the source code according to business requirements and then assembling the JSON data. For example, when the business needs to assemble JSON data like {"testkey":"testkeyValue123"}, the following code in the source code can be used to assemble a JSON data of {"testkey":"testkeyValue123"}.

[0039] Json::Value condition = Json::Value::null;

[0040] condition["testkey"] = "testkeyValue123";

[0041] The first sentence: Json::Value condition = Json::Value::null defines a Json type variable condition; The second sentence: condition["testkey"] = "testkeyValue123"; means setting the key of the condition variable to the string "testkey" and setting the value of the condition variable to the string "testkeyValue123".

[0042] Optionally, in the context of the running of a computer program, an executable file is a compiled program file that can be directly loaded and executed by the operating system.

[0043] Optionally, the first string is string data that the program needs to process during runtime. The first string can be a key-value or a key-value value in a JSON structure. The first string address is the virtual address of the first string in the process memory.

[0044] Step S204, search for the above first string address within the address range of the read-only constant area, where the above read-only constant area is N read-only constant data used to store the determined values during the compilation of the above target structured data in the above executable file, and the above N is a natural number greater than or equal to 1;

[0045] Optionally, the read-only constant area (.rodata section) is an area in an executable file in the Executable and Linkable Format (ELF for short) used to store read-only data determined during compilation, such as string literals, computed constants, etc. This area is not modifiable during program runtime, and its data is determined during compilation.

[0046] Step S206, when the first string address is within the above address range, reuse the target read-only constant data that matches the above first string from the N pieces of the above read-only constant data to instruct the executable file to process the above first string based on the above target read-only constant data.

[0047] Optionally, the N pieces of read-only constant data can be stored in a read-only constant data set. When the first string address is within the address range, reuse the target read-only constant data that matches the first string from the N pieces of read-only constant data in the read-only constant data set. For example, for a data processing application that needs to frequently process and compare JSON-formatted data. During the startup phase of the program, through ELF format parsing, all the read-only string resources in the read-only constant area have been extracted and stored in a read-only constant data set. This set contains 10 pieces of read-only constant data, such as "name", "age", "gender", etc. When the program runs, the memory address of the string "name" (corresponding to the above first string) that needs to be processed happens to be within the address range of the read-only constant area, which means that this string has been optimized during compilation and stored in the read-only area. The executable file processes "name" based on the target read-only production data, avoiding additional memory allocation and saving resources. For example, this set contains 100 pieces of read-only constant data, such as "employee", "department", "salary", etc. When the first string "department" needs to be processed, its memory address is also within the address range of the read-only constant area. At this time, reuse the target read-only constant data that matches "department" from the 100 pieces of read-only constant data. Another example is that the number of read-only constant data in the read-only constant data set may reach tens of thousands or more, such as "customer_id", "order_date", "product_name", etc. When processing the first string "product_name" and its address is within the read-only constant area range, at this time, reuse the target read-only constant data that matches "department" from the N pieces of read-only constant data. In this embodiment, the execution subject of the above steps can be a terminal, a server, a specific processor set in the terminal or the server, or a processor or processing device set relatively independently of the terminal or the server, but is not limited thereto.

[0048] Through the above steps, during the process of running the executable file, when the first string needs to be used, by searching for the address of the first string, if it is found that the address of this string is within the address range of the read-only constant area, it means that the string has been placed in the read-only constant area, and there is no need to allocate memory again for storage. The target read-only constant data that matches the first string can be directly reused, avoiding repeated memory allocation for the same string during runtime. This not only reduces the total memory occupied space but also avoids frequent memory allocation and release operations. Therefore, the problem of high consumption of string resources in the related art is solved, and the effect of reducing string resource consumption is achieved.

[0049] In an exemplary embodiment, before obtaining the first string address of the first string to be executed in the executable file during the process of running the executable file of the target structured data, the method further includes: when running the executable file, parsing the address information in the executable file to determine the address range of the read-only constant area; based on the address range of the read-only constant area, reading M original read-only constant data included in the read-only constant area; removing invisible characters in the M original read-only constant data to obtain N read-only constant data, where the invisible characters are used to represent non-text characters; setting the initial reference information for each read-only constant data, where the initial reference information for each read-only constant data is used to represent the number of times the string in each read-only constant data is initially referenced.

[0050] Optionally, whether the source code is compiled into an executable file in a static link manner or into a dynamic link library in a dynamic link manner after being compiled in a Linux environment, it is a file in ELF format. And the key is stored in the read-only constant area in the ELF file. Through the ELF format parsing method, the address range of the read-only constant area can be determined, and the content in the read-only constant area can be viewed. For example, by using the readelf -S <executable file name> of the tool readelf, the information of each section in the executable file can be viewed, including the address information of the read-only constant area. For example, by using the readelf -Wp.rodata <executable file name> of the tool readelf, the content in the read-only constant area can be viewed.

[0051] Optionally, the address information includes but is not limited to the start address and length of the read-only constant area.

[0052] Optionally, the original read-only constant data includes, but is not limited to, string literals determined at the compilation stage and related read-only data, such as numerical values, boolean values, etc. Invisible characters generally refer to non-text characters, such as control characters, formatting characters, etc. These characters are invisible in ordinary text display and processing, but may exist in the original read-only constant data. The read-only constant data includes, but is not limited to, the address information storing the string, the specific content of the string. For example,

[0053] [1afd]testkey;

[0054] [1b00]testkeyValue123;

[0055] Among them, 0x1afd in the first column represents the offset of the address storing the string "testkey" relative to the start address of the read-only constant area, and the second column represents the content of the read-only string "testkey".

[0056] Optionally, N read-only constant data and the initial reference information of each read-only constant data can be stored in a read-only constant data set. The initial reference information refers to the number of times each read-only constant data is referenced during the initialization stage of string resource management. Usually, it is initialized to 0, indicating that the string resource has not been referenced by any part of the program. The initial reference information will be updated after the read-only production data is referenced.

[0057] In this embodiment, when running the executable file, by parsing the address information in the file to determine the address range of the read-only constant area, it can enable the program to preferentially reuse the data in the read-only constant area when processing string resources, rather than reallocating memory in the heap or stack, achieving the purpose of effectively reducing memory consumption and improving memory usage efficiency. Further, removing the invisible characters in the original read-only constant data further purifies the stored string resources and avoids non-text characters occupying unnecessary memory space. Further, by setting the initial reference information of each read-only constant data, the purpose of monitoring and managing the string usage is achieved.

[0058] In an exemplary embodiment, when the above first string address is within the above address range, reusing the target read-only constant data that matches the above first string from the N above read-only constant data to instruct the above executable file to process the above first string based on the above target read-only constant data includes: when the above first string address is within the above address range, obtaining the target string in the above target read-only constant data according to the above first string address, where the address of the above target string is the same as the above first string address; running the above executable file based on the above target string to reuse the above target read-only constant data.

[0059] Optionally, when the executable file needs to process a string "temperature" (corresponding to the first string above), the memory address of this string (corresponding to the first string address above) is within the address range of the read-only constant area, indicating that the first string has been optimized by the compiler and exists in the read-only constant area. Based on the address of "temperature", the target read-only constant data that matches it can be found from the N read-only constant data sets, that is, the target string. Since "temperature" already has a corresponding storage in the read-only constant area, its address is the same as the address of the target string found. After finding the matching target string, the executable file processes the "temperature" field based on this existing target read-only constant data, rather than re-creating or allocating memory to store this string.

[0060] In this embodiment, when the first string address is within the address range of the read-only constant area, the target read-only constant data that exactly matches the first string is reused from the N read-only constant data, which can avoid allocating memory space for the same string multiple times and achieves the purpose of reducing memory resource occupation.

[0061] In an exemplary embodiment, after running the above executable file based on the above target string to reuse the above target read-only constant data, the method further includes: updating the reference information of the above target read-only constant data during the process of running the above executable file to obtain the first target reference information of the above target read-only constant data, where the reference information of the above target read-only constant data is used to represent the number of times the target string in the above target read-only constant data is referenced; updating the above first target reference information when the life cycle of the above target string is the first preset threshold.

[0062] Optionally, the first target reference information is used to represent the updated reference count information when the target string in the target read-only constant data is referenced during the running of the executable file. The reference information can be stored by a reference counter.

[0063] Optionally, the first preset threshold is a reference index set for the life cycle of the string, usually a positive integer, and is used to determine whether the string resource should be further managed or optimized. When the reference count is reduced to the first preset threshold, it indicates that the usage frequency or importance of the string resource has reached a specific level, and corresponding processing decisions can be made based on this information.

[0064] Optionally, when the life cycle of the above target string is the first preset threshold, updating the above first target reference information includes: the life cycle of the first string is the first preset threshold, and the JSON data destructor triggers the release of the string; receiving the address of the first string passed in from the outer layer, determining whether the address of the first string is within the address range of the read-only constant area. If it is within the address range, searching for the target read-only constant data that matches the first string among N read-only constant data, and decrementing the reference counter of the target read-only constant data by 1.

[0065] In this embodiment, by updating the reference information of the target read-only constant data, the resource management policy can be dynamically adjusted according to the actual usage of the string. It can identify which strings are frequently referenced, so as to give priority to ensuring the availability and efficient access of these resources. At the same time, for strings with fewer reference times, a more conservative memory policy can be adopted. For example, consider releasing or compressing storage when the preset threshold of the life cycle is reached. Further, by maintaining and updating the current reference information of the read-only constant data, the usage of the string resources can be monitored, achieving the purpose of quickly locating possible memory leakage or over-occupation problems.

[0066] In an exemplary embodiment, after searching for the address of the first string from the address range of the above read-only constant area, the method further includes: when the address of the first string is not within the above address range, searching for the target read-only constant data among N pieces of the above read-only constant data according to the first string, where the target string in the target read-only constant data is the same as the first string; when the target string is a constant data among N pieces of the above read-only constant data, running the executable file based on the target string and updating the reference information of the target read-only constant data to obtain the second target reference information of the target read-only constant data, where the reference information of the target read-only constant data is used to represent the number of times the target string in the target read-only constant data is referenced.

[0067] Optionally, for example, a real-time data analysis system that continuously receives and parses JSON data from various sensors. The data contains a large number of dynamically generated strings, such as sensor IDs, temperature readings, humidity readings, etc. To enable the system to operate efficiently, a string compression management module is adopted. This module is optimized for dynamically generated strings to reduce memory usage. When receiving a string of JSON data, the system parses each string therein. For example, when parsing "sensor ID" (corresponding to the first string above), but the address of this field (corresponding to the address of the first string above) is not within the address range of the read-only constant area. The system then looks for a target read-only constant data that matches "sensorID" among N read-only constant data. The system finds a target read-only constant data that exactly matches "sensor ID" among the N read-only constant data. This means that although "sensor ID" was not initially in the read-only constant area, the system can still reuse the previously existing string resources to reduce memory occupancy. The system runs an executable file based on this target string to process the relevant JSON data fields. Next, the system will update the reference information of the found target read-only constant data, updating it from the first reference count (assumed to be 1) to the second target reference information (assumed to be updated to 2), indicating that the number of times this target string is referenced has increased from 1 to 2. This process helps the system dynamically understand which string resources are being frequently used, so that more effective memory management and optimization strategies can be adopted.

[0068] In this embodiment, when the address of the first string is outside the address range of the read-only constant area, it is checked whether there is a target string in the N read-only constant data that is the same as the content of the first string. If so, the target string is reused instead of re-applying for a memory space for the first string, thus avoiding multiple allocations of memory space for strings with the same content and achieving the purpose of reducing the occupation of memory resources. Further, after reusing the target string, the reference information of this target read-only constant data is updated to obtain the second target reference information, achieving the purpose of enhancing the management of the life cycle of string resources.

[0069] In an exemplary embodiment, after finding the above-mentioned first string address from the address range of the above-mentioned read-only constant area, the method further includes: when the above-mentioned first string address is not within the above-mentioned address range and the target string in the above-mentioned target read-only constant data is not included in N pieces of the above-mentioned read-only constant data, searching for the above-mentioned target read-only constant data in the first read-only constant set according to the above-mentioned first string, where the above-mentioned target string is the same as the above-mentioned first string, the above-mentioned first read-only constant set includes a plurality of first read-only constant data and reference information of each of the above-mentioned first read-only constant data, and the reference information of the above-mentioned first read-only constant data is used to represent the number of times the string in each of the above-mentioned first read-only constant data is referenced; when the above-mentioned target string is included in the above-mentioned first read-only constant set, running the above-mentioned executable file based on the above-mentioned target string and updating the reference information of the above-mentioned target read-only constant data in the above-mentioned first read-only constant set to obtain the third target reference information of the above-mentioned target read-only constant data; when the life cycle of the above-mentioned target string is a second preset threshold, updating the above-mentioned third target reference information; when the updated third target reference information is a target threshold, deleting the above-mentioned target read-only constant data in the above-mentioned first read-only constant set and releasing the storage space of the above-mentioned target string.

[0070] Optionally, the first read-only constant set may be a heap space string information set. The read-only constant data in the read-only constant area does not include the first read-only constant data in the first read-only constant set.

[0071] Optionally, the second preset threshold may be the first preset threshold, which is a reference index set for the life cycle of a string and is usually a positive integer used to determine whether a string resource should be further managed or optimized. When the reference count is reduced to the first preset threshold, it indicates that the usage frequency or importance of the string resource has reached a specific level, and corresponding processing decisions can be made based on this information.

[0072] Optionally, when the life cycle of the above-mentioned target string is the first preset threshold, updating the above-mentioned first target reference information includes: the life cycle of the first string is the first preset threshold, and JSON data destruction triggers string release; receiving the address of the first string passed in from the outer layer, determining whether the address of the first string is within the address range of the read-only constant area, if not, searching for the target read-only constant data matching the first string in the first read-only constant set, and decrementing the reference counter of the target read-only constant data by 1.

[0073] Optionally, when the updated third target reference information is the target threshold, the target read-only constant data is deleted from the first read-only constant set, and the storage space of the target string is released, including: if the reference counter of the target read-only constant data is 0, indicating that the target string in the target read-only constant data is no longer referenced, the target read-only constant data is removed from the first read-only constant set and the heap space of the target string is released.

[0074] In this embodiment, by also reusing the additionally allocated heap space, it further avoids multiple memory space allocations for strings with the same content, achieving the purpose of reducing memory resource occupation. Further, by maintaining and updating the current reference information of the first read-only constant data, the purpose of monitoring the usage of string resources is achieved.

[0075] In an exemplary embodiment, when the first string address is outside the above address range and the target string in the target read-only constant data is not in the first read-only constant set, after finding the target read-only constant data in the second read-only constant set according to the first string, the method further includes: when the first string is not included in the first read-only constant set, applying for a first storage space to store the first string in the first storage space, obtaining the string of the first target read-only constant data; running the executable file based on the string of the first target read-only constant data; adding the first target read-only constant data to the first read-only constant set, and setting the initial reference information of the first target read-only constant data, where the initial reference information of the first target read-only constant data is used to represent the number of times the first string in each first target read-only constant data is initially referenced.

[0076] Optionally, the first storage space may be a heap space.

[0077] Optionally, for example, a data processing application that needs to frequently process and compare data in JSON format. During the startup phase of the program, through ELF format parsing, all read-only string resources in the read-only constant area have been extracted and stored in a read-only constant data set. This set contains multiple read-only constant data. The heap space string information set (corresponding to the above-mentioned first read-only constant set) contains multiple read-only constant data. The read-only constant data in the read-only constant area does not include the first read-only constant data in the first read-only constant set. When the program is running, the memory address (corresponding to the above-mentioned first string address) of the string "humi d ity" (corresponding to the above-mentioned first string) to be processed is not within the address range of the read-only constant area and not in the read-only constant data set. This means that "humi dity" may be dynamically generated during runtime, or it is a string that was not optimized and stored in the read-only constant area during the compilation of the executable file.

[0078] Next, check if there is any read-only constant data in the heap space string information set that matches "humidity". No read-only constant data matching "humidity" is found in the heap space string information set either. At this time, it is necessary to apply for the first storage space to store "humidity", and add the newly formed "humidity", that is, the first target read-only constant data, to the first read-only constant set to optimize the storage structure. At the same time, set the initial reference information of the first target read-only constant data, indicating the number of times "humidity" is first referenced.

[0079] In this embodiment, by dynamically applying for the first storage space to store the first string, forming the first target read-only constant data, and adding it to the first read-only constant set, combined with the reference counting initialization and monitoring mechanism, the purpose of efficient management and utilization of strings is achieved.

[0080] In an exemplary embodiment, when the above first string address is within the above address range, after reusing the target read-only constant data that matches the above first string from the N above read-only constant data to instruct the above executable file to process the above first string based on the above target read-only constant data, the method further includes: during the process of running the above executable file, obtaining the storage space usage information of the above executable file; calculating the storage space utilization rate of the above executable file based on the above storage space usage information and the storage space information of the target device; when the above storage space utilization rate is greater than a preset usage threshold, obtaining the first log information and the second log information of the above executable file, where the above first log information includes the read-only constant data among the N above read-only constant data whose reference information is greater than a third preset threshold, and the above second log information includes multiple first read-only constant data in the first read-only constant set and the reference information of each above first read-only constant data, the reference information of the read-only constant data is used to represent the number of times the string in each above read-only constant data is referenced, and the reference information of the above first read-only constant data is used to represent the number of times the string in each above first read-only constant data is referenced; determining the abnormal read-only constant data among the N above read-only constant data and the above first read-only constant set based on the reference information of the read-only constant data among the N above read-only constant data whose reference information is greater than the above third preset threshold and the reference information of the above first read-only constant data, where the above abnormal read-only constant data is the constant data that abnormally occupies the storage space.

[0081] Optionally, the storage space usage information of the executable file includes the memory usage of the process. The storage space information of the target device includes the total memory of the target device. The storage space utilization rate of the executable file is the quotient of the storage space usage information of the executable file and the storage space information of the target device.

[0082] Optionally, for example, a high-performance computing platform that runs multiple complex data processing applications, such as large-scale data analysis, artificial intelligence model training, etc., and these applications involve the processing and storage of a large amount of JSON data. During the process of running a certain executable file (i.e., a data processing application) on this platform, the platform continuously monitors its storage space usage, including the usage of virtual memory and physical memory. This information can be obtained through tools or APIs provided by the operating system, such as / proc / <pid> / status file (a method for obtaining process memory usage information in the Linux system). Based on the storage space usage information of the executable file and the total storage space of the target device, this platform calculates the storage space utilization rate of the executable file. When the storage space utilization rate exceeds the preset threshold, the platform automatically obtains the first log information and the second log information of the executable file. The first log information contains read-only constant data with reference information greater than the third preset threshold (for example, the reference count exceeds 1000 times) among N read-only constant data. These data may be frequently accessed JSON key names, such as "temperature", "humidity", etc. The second log information covers all the read-only constant data and their reference information in the first read-only constant set. Based on the first log information and the second log information, this platform analyzes the reference count of each read-only constant data to determine the constant data that abnormally occupies storage space. For example, if it is found that the reference count of some read-only constant data (such as a specific device ID or sensor name) is abnormally high, far exceeding other constant data, this may indicate problems in data processing or storage strategies, such as excessive string copying or unnecessary duplication of data structures stored in memory. After identifying the abnormal read-only constant data, the platform can take a series of optimization measures, including but not limited to: dynamically adjusting the storage strategy of read-only constant data, such as moving frequently referenced strings to faster caches or storage media to reduce memory access latency. Reviewing and optimizing data processing logic to avoid unnecessary string generation and storage. Adding an abnormal monitoring mechanism to track the generation and use of abnormal read-only constant data in real time and making timely adjustments to avoid potential memory leaks or resource waste.

[0083] In this embodiment, by monitoring the storage space usage of the executable file during runtime and obtaining the first log information and the second log information of the executable file based on the storage space usage, the purpose of abnormal location and processing of string resources based on this log information is achieved. In the scenario of memory overload, the information and reference information of read-only production data can be printed to improve locatability. This not only optimizes the use of memory resources, improves the stability and execution efficiency of the program, but also provides clear resource management information for developers and system maintenance personnel.

[0084] The present invention will be described below with reference to specific embodiments:

[0085] This embodiment is described by taking a data processing device as an example. This device runs multiple complex processes, such as processes for large-scale data analysis, processes for artificial intelligence model training, etc. The operation of these processes involves the processing and storage of a large amount of JSON data, such as Figure 3 as shown Figure 3 is a flowchart of a method for compressing a string according to a specific embodiment of the present application:

[0086] S302, start.

[0087] S304, Parse the executable file running in the ELF format to obtain the address range of the.rodatasection of the executable file running.

[0088] S306, Read the content in the.rodata section, remove the invisible characters to obtain a read-only constant string set, and set the reference counter of each string unit in the set to 0.

[0089] S308, The string compression management module determines whether the first string address of the first string passed in is within the.rodata section address range. If so, go to S312; otherwise, go to S310.

[0090] S310, Not within this address range. Determine whether there are string units with the same content among the N read-only constant data in the read-only constant string set (i.e., the above-mentioned target read-only constant data). If so, go to S312; otherwise, go to S314.

[0091] S312, When the first string address passed in is within this address range, it means that the compiler directly uses the string in the read-only constant area to form JSON information, directly reuse this string unit, increment the reference counter of this string unit in the read-only constant string set, and do not need to apply for additional memory space to store this string information.

[0092] When the first string address passed in is from the heap space or the stack space, for example:

[0093] Json::Value condition = Json::Value::null;

[0094] char acStackBuf

[256] = {0}; / / acBuf is 256 bytes and is the stack space;

[0095] sprintf(acStackBuf, "%s", "testkey-inStack"); / / Assign key value (key) information in the stack space;

[0096] condition[acStackBuf] = "value-inStack"; / / Pass the stack space address into the key value (key) information;

[0097] char* pcHeap = (char*)malloc(256); / / pcHeap is 256 bytes and is the heap space;

[0098] sprintf(pcHeap, "%s", "testkey-inHeap"); / / Assign key information in the heap space;

[0099] condition[pcHeap] = "value-inHeap"; / / Pass the heap space address to the key information;

[0100] The addresses of these strings are outside this address range, but there are strings with the same content in the read-only constant area. Directly reuse this string unit, increment the reference counter of this string unit in the read-only constant string set, and do not need to apply for additional memory space to store this string information.

[0101] S314, Check whether there is the same string unit in the heap space string information set (i.e., the above first read-only constant set). If yes, go to S316; otherwise, go to S318.

[0102] S316, In the heap space string information set, reuse this string unit in the heap space string information set, increment the reference counter of this string unit in the heap space string information set, and do not need to apply for additional memory space to store this string information.

[0103] S318, Not in the heap space string information set, apply for additional heap space to store this string information, add this string unit to the heap space string information set, and set the reference counter value of this string unit in the heap space string information set.

[0104] S320, End.

[0105] As Figure 4 shown, Figure 4 is the flowchart of a method for releasing processing of a string in a specific embodiment of this application:

[0106] S402, Start.

[0107] S404, The life cycle of the first string ends, and the JSON data destructor triggers the release of the string.

[0108] S406, The string compression management module receives the first string address of the first string passed in from the outside layer, and checks whether it is within the address range of the.rodata section. If yes, go to S412; otherwise, go to S408.

[0109] S408, Not within the address range of the.rodata section, search for the same string unit in the heap space string information set, and decrement the reference counter of this string unit in the heap space string information set;

[0110] S410, if the reference counter of the string unit in the heap space string information set is 0, it means that the string unit is not referenced, and the string unit is removed from the heap space string information set and the string heap space is released.

[0111] S412, within the address range of the.rodata section, decrement the reference counter of the string unit by 1.

[0112] S414, end.

[0113] As Figure 5 shown, Figure 5 is a flowchart of a method for locating and processing strings in a specific embodiment of the present application:

[0114] S502, start.

[0115] S504, regularly obtain the memory usage of the process and the total memory of the target device, and divide the two to obtain the process memory usage rate.

[0116] S506, determine whether the process memory usage rate exceeds a relatively high threshold, such as 95%, if so, go to S508, otherwise go to S512.

[0117] S508, traverse the heap space string information set, and record the string information and the value of the reference counter of each string unit in the heap space string information set through logging (i.e., the above second log information).

[0118] S510, traverse the read-only constant string set, and record the string information and the value of the reference counter of the string units with a reference counter greater than 0 in each string unit in the read-only constant string set through logging (i.e., the above first log information).

[0119] S512, when the process memory is exhausted due to JSON string leakage, based on the string information and the value of the reference counter of the string units in the first log information and the second log information, count which specific string units use more memory resources, quickly locate the abnormal string units, and improve the locatability.

[0120] Through the description of the above embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be implemented by means of software plus a necessary general hardware platform. Of course, it can also be implemented by hardware, but in many cases the former is a better implementation. Based on such an understanding, the technical solution of the present application, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. The computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes several instructions for causing a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods of the various embodiments of the present application.

[0121] In this embodiment, a string processing device is further provided. The device is used to implement the above embodiments and preferred implementation manners, and those that have been described will not be repeated. As used below, the term "module" can be a combination of software and / or hardware that can achieve a predetermined function. Although the systems described in the following embodiments are preferably implemented in software, implementation in hardware, or a combination of software and hardware is also possible and contemplated.

[0122] Figure 6 is a structural block diagram of a string processing device according to an embodiment of the present application. As Figure 6 shown, the device includes:

[0123] A first acquisition module 602, configured to acquire a first string address of a first string to be executed in the executable file during the process of running the executable file of the target structured data, where the target structured data is structured data for implementing a target task;

[0124] A first search module 604, configured to search for the first string address from the address range of the read-only constant area, where the read-only constant area is N read-only constant data for storing determined values during the compilation of the target structured data in the executable file, and N is a natural number greater than or equal to 1;

[0125] A first processing module 606, configured to, when the first string address is within the address range, reuse a target read-only constant data that matches the first string from the N read-only constant data to instruct the executable file to process the first string based on the target read-only constant data.

[0126] In an exemplary embodiment, the above device further includes: a first parsing module, configured to parse the address information in the executable file when running the executable file of the target structured data to determine the address range of the read-only constant area before obtaining the first string address of the first string to be executed in the executable file; a first reading module, configured to read M original read-only constant data included in the read-only constant area based on the address range of the read-only constant area; a first removing module, configured to remove invisible characters in the M original read-only constant data to obtain N read-only constant data, where the invisible characters are used to represent non-text characters; a first setting module, configured to set the initial reference information of each read-only constant data, where the initial reference information of each read-only constant data is used to represent the number of times the string in each read-only constant data is initially referenced.

[0127] In an exemplary embodiment, the above first processing module includes: a first obtaining sub-module, configured to obtain the target string in the target read-only constant data according to the first string address when the first string address is within the address range, where the address of the target string is the same as the first string address; a first reusing sub-module, configured to run the executable file based on the target string to reuse the target read-only constant data.

[0128] In an exemplary embodiment, the above first processing module further includes: a first updating sub-module, configured to update the reference information of the target read-only constant data to obtain the first target reference information of the target read-only constant data when running the executable file after reusing the target read-only constant data by running the executable file based on the target string, where the reference information of the target read-only constant data is used to represent the number of times the target string in the target read-only constant data is referenced; a second updating sub-module, configured to update the first target reference information when the life cycle of the target string is a first preset threshold.

[0129] In an exemplary embodiment, the above-mentioned device further includes a second search module, configured to search for the above-mentioned first string address from the address range of the above-mentioned read-only constant area. In the case where the above-mentioned first string address is not within the above-mentioned address range, according to the above-mentioned first string, search for the above-mentioned target read-only constant data in N pieces of the above-mentioned read-only constant data, where the target string in the above-mentioned target read-only constant data is the same as the above-mentioned first string; a first execution module, configured to, in the case where the above-mentioned target string is a constant data among N pieces of the above-mentioned read-only constant data, execute the above-mentioned executable file based on the above-mentioned target string, and update the reference information of the above-mentioned target read-only constant data to obtain the second target reference information of the above-mentioned target read-only constant data, where the reference information of the above-mentioned target read-only constant data is used to represent the number of times the target string in the above-mentioned target read-only constant data is referenced.

[0130] In an exemplary embodiment, the above-mentioned device further includes a third search module, configured to search for the above-mentioned first string address from the address range of the above-mentioned read-only constant area. In the case where the above-mentioned first string address is not within the above-mentioned address range and the target string in the above-mentioned target read-only constant data is not included in N pieces of the above-mentioned read-only constant data, according to the above-mentioned first string, search for the above-mentioned target read-only constant data in a first read-only constant set, where the target string is the same as the above-mentioned first string, the first read-only constant set includes a plurality of first read-only constant data and the reference information of each piece of the above-mentioned first read-only constant data, and the reference information of the above-mentioned first read-only constant data is used to represent the number of times the string in each piece of the above-mentioned first read-only constant data is referenced; a second execution module, configured to, in the case where the above-mentioned target string is included in the above-mentioned first read-only constant set, execute the above-mentioned executable file based on the above-mentioned target string, and update the reference information of the above-mentioned target read-only constant data in the above-mentioned first read-only constant set to obtain the third target reference information of the above-mentioned target read-only constant data; a third update module, configured to update the above-mentioned third target reference information in the case where the life cycle of the above-mentioned target string is a second preset threshold; a first release module, configured to, in the case where the updated third target reference information is a target threshold, delete the above-mentioned target read-only constant data in the above-mentioned first read-only constant set, and release the storage space of the above-mentioned target string.

[0131] In an exemplary embodiment, the above-mentioned device further includes: a first storage module, configured to, when the above-mentioned first string address is outside the above-mentioned address range and the target string in the target read-only constant data is not in the above-mentioned first read-only constant set, after looking up the above-mentioned target read-only constant data in the second read-only constant set according to the above-mentioned first string, when the above-mentioned first string is not included in the above-mentioned first read-only constant set, apply for a first storage space to store the above-mentioned first string in the above-mentioned first storage space, and obtain the string of the first target read-only constant data; a second operation module, configured to run the above-mentioned executable file based on the string of the above-mentioned first target read-only constant data; a first addition module, configured to add the above-mentioned first target read-only constant data to the above-mentioned first read-only constant set and set the initial reference information of the above-mentioned first target read-only constant data, where the initial reference information of the above-mentioned first target read-only constant data is used to represent the number of times the first string in each of the above-mentioned first target read-only constant data is initially referenced.

[0132] In an exemplary embodiment, the above-mentioned device further includes: when the above-mentioned first string address is within the above-mentioned address range, reusing the target read-only constant data that matches the above-mentioned first string from N pieces of the above-mentioned read-only constant data to instruct the above-mentioned executable file to process the above-mentioned first string based on the above-mentioned target read-only constant data, the above-mentioned method further includes: a second acquisition module, configured to acquire the storage space usage information of the above-mentioned executable file during the process of running the above-mentioned executable file; a first calculation module, configured to calculate the storage space utilization rate of the above-mentioned executable file based on the above-mentioned storage space usage information and the storage space information of the target device; a third acquisition module, configured to, when the above-mentioned storage space utilization rate is greater than a preset usage threshold, acquire the first log information and the second log information of the above-mentioned executable file, where the above-mentioned first log information includes the read-only constant data whose reference information in N pieces of the above-mentioned read-only constant data is greater than a third preset threshold, the above-mentioned second log information includes a plurality of first read-only constant data in the first read-only constant set and the reference information of each of the above-mentioned first read-only constant data, the reference information of the above-mentioned read-only constant data is used to represent the number of times the string in each of the above-mentioned read-only constant data is referenced, and the reference information of the above-mentioned first read-only constant data is used to represent the number of times the string in each of the above-mentioned first read-only constant data is referenced; a first determination module, configured to determine the abnormal read-only constant data in N pieces of the above-mentioned read-only constant data and the above-mentioned first read-only constant set based on the reference information of the read-only constant data whose reference information in N pieces of the above-mentioned read-only constant data is greater than the above-mentioned third preset threshold and the reference information of the above-mentioned first read-only constant data, where the above-mentioned abnormal read-only constant data is the constant data that abnormally occupies the storage space.

[0133] Embodiments of the present application provide a computer program product, including a computer program, where when the computer program is executed by a processor, the steps in any of the above method embodiments are implemented.

[0134] Embodiments of the present application further provide a computer-readable storage medium, in which a computer program is stored, and the computer program is configured to execute the steps in any of the above method embodiments when running.

[0135] In an exemplary embodiment, the above computer-readable storage medium may include, but is not limited to: various media such as USB flash drives, read-only memories (ROMs for short), random access memories (RAMs for short), mobile hard disks, magnetic disks, or optical discs that can store computer programs.

[0136] Embodiments of the present application further provide an electronic device, including a memory and a processor, where a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any of the above method embodiments.

[0137] In an exemplary embodiment, the above electronic device may further include a transmission device and an input / output device, where the transmission device is connected to the processor, and the input / output device is connected to the processor.

[0138] Specific examples in this embodiment may refer to the examples described in the above embodiments and exemplary embodiments, and will not be repeated here.

[0139] Obviously, those skilled in the art should understand that the above modules or steps of the present application can be implemented by a general-purpose computing device. They can be concentrated on a single computing device or distributed on a network composed of multiple computing devices. They can be implemented by program codes executable by the computing device, so that they can be stored in a storage device and executed by the computing device. And in some cases, the steps shown or described can be executed in a different order from here, or they can be separately made into individual integrated circuit modules, or multiple modules or steps among them can be made into a single integrated circuit module to implement. In this way, the present application is not limited to any specific combination of hardware and software.

[0140] The above are only the preferred embodiments of the present application and are not used to limit the present application. For those skilled in the art, the present application can have various changes and modifications. Any updates, equivalent replacements, improvements, etc. made within the principle of the present application shall be included in the protection scope of the present application.< / pid>

Claims

1. A method for processing a string, characterized in that, Including: During the process of running an executable file for target structured data, obtain a first string address of a first string to be executed in the executable file, where the target structured data is structured data for implementing a target task; Search for the first string address within an address range of a read-only constant area, where the read-only constant area is N read-only constant data for storing determined values during compilation of the target structured data in the executable file, and N is a natural number greater than or equal to 1; When the first string address is within the address range, reuse a target read-only constant data that matches the first string from the N read-only constant data to instruct the executable file to process the first string based on the target read-only constant data.

2. The method according to claim 1, wherein Before obtaining the first string address of the first string to be executed in the executable file during the process of running the executable file for target structured data, the method further includes: When running the executable file, parse address information in the executable file to determine the address range of the read-only constant area; Based on the address range of the read-only constant area, read M original read-only constant data included in the read-only constant area; Remove invisible characters from the M original read-only constant data to obtain the N read-only constant data, where the invisible characters are used to represent non-text characters; Set initial reference information for each read-only constant data, where the initial reference information for each read-only constant data is used to represent the number of times the string in each read-only constant data is initially referenced.

3. The method according to claim 1 or 2, characterized in that, When the first string address is within the address range, reusing a target read-only constant data that matches the first string from the N read-only constant data to instruct the executable file to process the first string based on the target read-only constant data includes: When the first string address is within the address range, obtain a target string in the target read-only constant data according to the first string address, where the address of the target string is the same as the first string address; Run the executable file based on the target string to reuse the target read-only constant data.

4. The method according to claim 3, wherein After running the executable file based on the target string to reuse the target read-only constant data, the method further includes: During the process of running the executable file, update the reference information of the target read-only constant data to obtain first target reference information of the target read-only constant data, where the reference information of the target read-only constant data is used to represent the number of times the target string in the target read-only constant data is referenced; When the life cycle of the target string is a first preset threshold, update the first target reference information.

5. The method according to claim 1 or 2, characterized in that After searching for the first string address within the address range of the read-only constant area, the method further includes: In the case that the first string address is not within the address range, search for the target read-only constant data among the N read-only constant data according to the first string, where the target string in the target read-only constant data is the same as the first string; In the case that the target string is the constant data among the N read-only constant data, run the executable file based on the target string, and update the reference information of the target read-only constant data to obtain the second target reference information of the target read-only constant data, where the reference information of the target read-only constant data is used to represent the number of times the target string in the target read-only constant data is referenced.

6. The method according to claim 1 or 2, characterized in that, After searching for the first string address from the address range of the read-only constant area, the method further includes: In the case that the first string address is not within the address range and the target string in the target read-only constant data is not included in the N read-only constant data, search for the target read-only constant data in the first read-only constant set according to the first string, where the target string is the same as the first string, the first read-only constant set includes a plurality of first read-only constant data and the reference information of each first read-only constant data, and the reference information of the first read-only constant data is used to represent the number of times the string in each first read-only constant data is referenced; In the case that the target string is included in the first read-only constant set, run the executable file based on the target string, and update the reference information of the target read-only constant data in the first read-only constant set to obtain the third target reference information of the target read-only constant data; In the case that the life cycle of the target string is a second preset threshold, update the third target reference information; In the case that the updated third target reference information is a target threshold, delete the target read-only constant data in the first read-only constant set and release the storage space of the target string.

7. The method according to claim 6, wherein In the case that the first string address is outside the address range and the target string in the target read-only constant data is not in the first read-only constant set, after searching for the target read-only constant data in the second read-only constant set according to the first string, the method further includes: In the case that the first string is not included in the first read-only constant set, apply for a first storage space to store the first string in the first storage space to obtain the string of the first target read-only constant data; Run the executable file based on the string of the first target read-only constant data; Add the first target read-only constant data to the first read-only constant set and set the initial reference information of the first target read-only constant data, where the initial reference information of the first target read-only constant data is used to represent the number of times the first string in each first target read-only constant data is initially referenced.

8. The method according to claim 1, wherein When the first string address is within the address range, after reusing, from the N read-only constant data, the target read-only constant data that matches the first string to indicate that the executable file processes the first string based on the target read-only constant data, the method further includes: During the process of running the executable file, obtaining the storage space usage information of the executable file; Calculating the storage space utilization rate of the executable file based on the storage space usage information and the storage space information of the target device; When the storage space utilization rate is greater than a preset usage threshold, obtaining first log information and second log information of the executable file, where the first log information includes the read-only constant data in the N read-only constant data whose reference information is greater than a third preset threshold, and the second log information includes multiple first read-only constant data in a first set of read-only constant data and the reference information of each of the first read-only constant data, the reference information of the read-only constant data is used to represent the number of times the string in each read-only constant data is referenced, and the reference information of the first read-only constant data is used to represent the number of times the string in each first read-only constant data is referenced; Based on the reference information of the read-only constant data in the N read-only constant data whose reference information is greater than the third preset threshold, and the reference information of the first read-only constant data, determining the abnormal read-only constant data in the N read-only constant data and the first set of read-only constant data, where the abnormal read-only constant data is the constant data that abnormally occupies storage space.

9. A processing device for a string, characterized in that, Including: A first obtaining module, configured to obtain, during the process of running an executable file of target structured data, a first string address of a first string to be executed in the executable file, where the target structured data is structured data for implementing a target task; A first searching module, configured to search for the first string address from an address range of a read-only constant area, where the read-only constant area is N read-only constant data for storing determined values during the compilation of the target structured data in the executable file, and N is a natural number greater than or equal to 1; A first processing module, configured to, when the first string address is within the address range, reuse, from the N read-only constant data, the target read-only constant data that matches the first string to indicate that the executable file processes the first string based on the target read-only constant data.

10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method described in any one of claims 1 to 8.

11. A computer-readable storage medium, characterized in that, A computer-readable storage medium stores a computer program, where, when the computer program is executed by a processor, it implements the steps of the method described in any one of claims 1 to 8.

12. An electronic device, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method described in any one of claims 1 to 8.