Multi-instance static object access method and device, storage medium and related equipment
By defining static and non-static array object collections in the function package, the problem of insufficient utilization of RAM resources in the function package development is solved, effective access to shared resources by multiple applications and reasonable allocation of memory, and the utilization of RAM resources is improved Rate.
Patent Information
- Application Number
- CN202411351258.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-26
- Publication Date
- 2024-12-20
AI Technical Summary
When developing function packages, the limited RAM resources in the card are not fully utilized and cannot balance the memory requirements of each application. Static array objects cause the first instantiated application to be accessed by other instances, and non-static array objects cause repeated memory allocation. and deficiencies.
By defining a collection of static array objects and non-static array objects in the function package, the static array objects are used as the global resource pool, and data access is achieved through pointers to non-static array objects, avoiding firewall restrictions and repeat memory allocation.
It improves the utilization rate of RAM resources, reduces the risk of instantiation failure caused by insufficient memory, and realizes effective access to shared resources by various applications and reasonable allocation of memory.
Smart Images

Figure CN119166112A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of network information technology, and in particular to a method, device, storage medium and computer equipment for accessing multiple instances of static objects. Background Art
[0002] With the rapid development of smart card technology, the concept of one card with multiple applications has gained increasing attention, which aims to carry diverse applications through limited card space. To achieve this goal, the industry generally adopts an efficient software architecture model, which is to decompose it into function packages and multiple application packages. Function packages, as core components, integrate resources shared by various applications, which can effectively reduce code duplication, optimize the use of RAM resources, and provide more space for cards to carry new applications.
[0003] However, when developing a function package, if the array objects in the function package are set to static, only the first instantiated application will be able to access it without obstacles, but other applications that are instantiated subsequently may not be able to access it due to the blockage of the security firewall, resulting in insufficient resource utilization; on the contrary, if these array objects are set to non-static, when there are multiple instances of the same application, each instance will initialize these objects independently, resulting in repeated allocation of RAM space, which in turn leads to insufficient memory. In short, when developing a function package, the limited RAM resources in the card are not fully utilized, and the memory requirements of various applications cannot be balanced. Summary of the invention
[0004] The purpose of this application is to solve at least one of the above-mentioned technical defects, especially the technical defect in the prior art that when developing function packages, the limited RAM resources in the card are not fully utilized and the memory requirements of various applications cannot be balanced.
[0005] The present application provides a multi-instance static object access method, which is applied to a multi-application project, including a function package and multiple application packages. The method includes:
[0006] A static array object set and a non-static array object are defined in the function package; wherein the static array object set includes a plurality of static array objects;
[0007] For each application package, instantiate the application in the application package to obtain a first instance, and extract a static array object from the static array object set to allocate space for the first instance to form a target array object of the application; point the pointer of the non-static array object to the target array object, and use the first instance to access data of the target array object;
[0008] When an application in any application package is instantiated again to generate a second instance, the target array object of the application is determined, the pointer of the non-static array object is pointed to the target array object, and the second instance is used to access data of the target array object.
[0009] Optionally, the static array object set is defined in the function package, including:
[0010] Determine the number of applications in each application package and summarize them to obtain the total number of applications;
[0011] In the function package, a number of static array objects corresponding to the total number of application programs is defined to form a static array object set.
[0012] Optionally, extracting a static array object from the static array object set to allocate space for the first instance includes:
[0013] Extracting a static array object from the static array object set, and initializing the static array object;
[0014] A RAM space is allocated for the initialized static array object so that the first instance uses the RAM space.
[0015] Optionally, the step of pointing the pointer of the non-static array object to the target array object and using the first instance to access data of the target array object comprises:
[0016] Assigning the target array object to the non-static data object so that the non-static array object points to the RAM space of the target array object;
[0017] The non-static data object is referenced through the first instance to access data in the RAM space of the target array object.
[0018] Optionally, the method further comprises:
[0019] When any application package in the multi-application project includes multiple applications, a corresponding target array object is determined for each application based on the static array object set; wherein the target array object of each application is different.
[0020] Optionally, the method further comprises:
[0021] When deleting an instance in the multi-application project, determining a target array object corresponding to the instance, and judging whether the instance is the last instance in the target array object;
[0022] If so, after the instance is deleted, the RAM space of the target array object is released to form a static array object, and the static array object is added to the static array object set;
[0023] If not, the instance is deleted directly.
[0024] The present application also provides a static object access device, which is applied to a multi-application project, including a function package and multiple application packages, and the device includes:
[0025] An object definition module, used to define a static array object set and a non-static array object in the function package; wherein the static array object set includes a plurality of static array objects;
[0026] A first access module is used to instantiate the application in each application package to obtain a first instance, and extract a static array object from the static array object set to allocate space to the first instance to form a target array object of the application; point the pointer of the non-static array object to the target array object, and use the first instance to access data of the target array object;
[0027] The second access module is used to determine the target array object of the application when the application in any application package is instantiated again to generate a second instance, so as to point the pointer of the non-static array object to the target array object, and use the second instance to access data of the target array object.
[0028] Optionally, the device further comprises:
[0029] The total number determination submodule is used to determine the number of applications in each application package and summarize the total number of applications;
[0030] The collection definition submodule is used to define static array objects in the function package whose number corresponds to the total number of application programs to form a static array object collection.
[0031] The present application also provides a storage medium, in which computer-readable instructions are stored. When the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the static object access method described in any one of the above embodiments.
[0032] The present application also provides a computer device, comprising: one or more processors, and a memory;
[0033] The memory stores computer-readable instructions, and when the computer-readable instructions are executed by the one or more processors, the steps of the static object access method described in any one of the above embodiments are performed.
[0034] It can be seen from the above technical solutions that the embodiments of the present application have the following advantages:
[0035] The present application provides a multi-instance static object access method, device, storage medium and related equipment. The method is applied to multi-application projects, including a function package and multiple application packages. When developing the function package, a static array object set and a non-static array object can be first defined in the function package; wherein the static array object set includes multiple static array objects, which serve as a global resource pool, allowing sufficient memory space to be allocated to each application at one time; and the non-static array object can be used to reference the static array object in the static array object set, thereby improving code reusability; therefore, the present application can allocate respective static array objects to the applications in each application package through the static array object set, and when the application is instantiated, only initialize and allocate space for the respective static array objects, and realize access to shared resources by each instantiated application through the pointer mechanism of the non-static array object, while avoiding firewall restrictions, it can avoid repeated allocation of the same size of memory space to multiple instances of the same application, thereby improving the utilization rate of RAM resources and reducing the risk of instantiation failure due to insufficient memory. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0037] Figure 1 A schematic diagram of a static object access method provided in an embodiment of the present application;
[0038] Figure 2 A logical schematic diagram of a multi-application project provided for an embodiment of the present application;
[0039] Figure 3 A schematic diagram of the structure of a static object access device provided in an embodiment of the present application;
[0040] Figure 4 A schematic diagram of the internal structure of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0041] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0042] When developing a function package, if the array objects in the function package are set to static, only the first instantiated application will be able to access it without obstacles, but other applications that are instantiated subsequently may not be able to access it due to the blockage of the security firewall, resulting in insufficient resource utilization; on the contrary, if these array objects are set to non-static, when there are multiple instances of the same application, each instance will initialize these objects independently, resulting in repeated allocation of RAM space, which in turn leads to insufficient memory. In short, when developing a function package, the limited RAM resources in the card are not fully utilized, and the memory requirements of various applications cannot be balanced.
[0043] Based on this, this application proposes the following technical solutions, see below for details:
[0044] In one embodiment, Figure 1 As shown, Figure 1 A flow chart of a static object access method provided in an embodiment of the present application; the present application provides a static object access method, which is applied to a multi-application project, including a function package and multiple application packages, and the method specifically includes the following:
[0045] S110: defining a static array object set and a non-static array object in a function package; wherein the static array object set includes a plurality of static array objects.
[0046] In this step, when the user develops a function package in a multi-application project, a static array object set and a non-static array object can be defined in the function package through a computer device. The static array object set can include multiple static array objects, which serve as a global resource pool to allow sufficient memory space to be allocated to each application at one time; and the non-static array object can be used to reference the static array object in the static array object set to improve code reusability.
[0047] It is understandable that in a multi-application project, a function package refers to a group of function modules or class libraries that encapsulate specific functions or services and can be reused in multiple applications; and an application package can contain one or more applications to implement specific business logic, such as payment, identity authentication, access control, etc. Therefore, the function package can provide support for the applications in each application package to enable them to implement the corresponding business functions.
[0048] Furthermore, a static array object is an array defined in a class of a function package, modified with the static keyword, and the array object belongs to the class itself, not any specific instance of the class. Therefore, no matter how many instances of the class are created, there is only one copy of the static array object, and all instances share this copy; and a non-static array object is also an array defined in a class of a function package, but is not modified with the static keyword, so each instance of the created class has its own copy of the array. In the present application, a computer device can define the applications in each application package as static array objects, so that it can save space in multiple instantiations, and then define a non-static array object as a pointer to reference the static array objects obtained by each definition, thereby reducing the extra overhead caused by avoiding firewall restrictions.
[0049] S120: For each application package, instantiate the application in the application package to obtain a first instance, and extract a static array object from the static array object set to allocate space for the first instance to form a target array object of the application; point the pointer of the non-static array object to the target array object, and use the first instance to access data of the target array object.
[0050] In this step, after the static array object set and the non-static array object are defined in step S110, for each application package in the multi-application project, the computer device can instantiate the application in the application package to obtain a first instance, and then extract a static array object from the static array object set to allocate space for the first instance to form a target array object of the application; then the computer device can point the pointer of the non-static array object to the target array object, and use the first instance to access data of the target array object.
[0051] Specifically, before instantiating an application in an application package, the computer device can first extract a static array object from a defined static array object set, and after the application is instantiated as a first instance, the computer device can allocate space for the first instance through the static array object, and use the static array object as the target array object of the application, so that data can be accessed exclusively by the instance of the application, thereby avoiding firewall restrictions by avoiding access by other applications.
[0052] Then, after determining the target array object of the application, the computer device can further point the pointer of the non-static array object defined in the function package to the target array object. Through this pointer mechanism, the first instance can directly access and operate the data in the target data object through the non-static array object without recreating or allocating additional memory.
[0053] It is understandable that during the instantiation process, the computer device uses the association between the application and the target array object to implement read and write operations on the target array object through the pointer of the non-static array object. This allows the application to flexibly access and modify the data in the target array object during operation, thereby realizing instance-level data management and operation. Each instantiated application can perform personalized operations on the content in the corresponding target array object according to its own needs without affecting the operation of other instances, thereby making reasonable use of RAM resources and ensuring that each instance can still have an independent operating space under the premise of sharing resources.
[0054] S130: When an application in any application package is instantiated again to generate a second instance, a target array object of the application is determined to point a pointer of the non-static array object to the target array object, and the second instance is used to access data of the target array object.
[0055] In this step, after obtaining the target array object corresponding to each application through step S120, if the application in any application package still needs to be instantiated again, the computer device can generate a second instance of the application, and then determine the target array object of the application from each target array object, and then directly point the pointer of the non-static array object in the function package to the target array object, so that the second instance can be used to access data of the target array object, so that multiple instances of the application can share the data structure or resources in the target array object, avoiding repeated copying of the target array object and causing waste of resources.
[0056] It is understandable that, in the process of instantiating each application, the computer device will allocate the corresponding target array object when each application generates the first instance. However, in the actual operation process, it is often necessary to create multiple instances for the application in the same application package to cope with different operation scenarios or user requests. In order to support this multi-instance scenario, the computer device needs to generate a second instance of the application when instantiating the application in the application package again.
[0057] Specifically, in the process of generating the second instance, the computer device can first query and judge from the various target array objects formed previously to determine the target array object corresponding to the application to which the second instance belongs. Since the target array object has allocated space for the first instance, the second instance can reuse the RAM space of the target array object for temporary data caching without repeating memory allocation or object copying. Based on this, the computer device can directly point the pointer of the non-static array object in the function package to the target array object, so that the second instance can access and operate the data structure and resources in the target array object like the first instance, which can not only improve the efficiency of memory use, but also avoid the waste of resources caused by repeated copying of the target array object.
[0058] For example, in a multi-instance scenario, if the first instance has stored some data in the target array object, the second instance can directly access and utilize the RAM space of the target array object through a shared pointer without reinitialization or copying. This data sharing method not only reduces the memory burden of the integrated card, but also ensures the collaboration between applications, allowing multiple instances to perform similar tasks simultaneously without conflict.
[0059] In the above embodiment, the method is applied to a multi-application project, including a function package and multiple application packages. When developing a function package, a static array object set and a non-static array object can be first defined in the function package; wherein, the static array object set includes multiple static array objects, which serve as a global resource pool, allowing sufficient memory space to be allocated to each application at one time; and the non-static array object can be used to reference the static array object in the static array object set to improve code reusability; therefore, the present application can allocate respective static array objects to the applications in each application package through the static array object set, and when the application is instantiated, only initialize and allocate space for the respective static array objects, and through the pointer mechanism of the non-static array object, access to shared resources by each instantiated application is realized, while avoiding firewall restrictions, it can avoid repeated allocation of the same size of memory space to multiple instances of the same application, thereby improving the utilization of RAM resources and reducing the risk of instantiation failure due to insufficient memory.
[0060] In one embodiment, in step S110, a static array object set is defined in the function package, including:
[0061] S111: Determine the number of applications in each application package, and summarize to obtain the total number of applications.
[0062] S112: defining in the function package a number of static array objects corresponding to the total number of application programs to form a static array object set.
[0063] In this embodiment, when a computer device defines a static array object set in a function package, it can first determine the number of applications in each application package, and then summarize the total number of applications in the multi-application project. The computer device can then define a number of static array objects in the function package that corresponds to the total number of applications to form a static array object set.
[0064] It is understandable that each application package contains one or more independent applications, and these applications need to use certain memory resources and structural data when running; in other words, during the instantiation process, each application needs to allocate a corresponding static array object to avoid data interference or resource conflicts. Therefore, when defining a static array object collection in a function package, it is necessary to first determine the total number of applications in each application package, and then define a number of static array objects corresponding to the total number of applications in the function package. In this way, each static array object can provide memory space for an application when instantiated, and store data that needs to be shared or accessed during its operation, so that RAM resources can be reasonably allocated to avoid unnecessary resource waste or shortage.
[0065] In one embodiment, extracting a static array object from the static array object set to allocate space to the first instance in step S120 may include:
[0066] S121: extract a static array object from the static array object set, and initialize the static array object.
[0067] S122: Allocate RAM space for the initialized static array object so that the first instance uses the RAM space.
[0068] In this embodiment, when the computer device allocates space for the first instance, it can first extract a static array object from the static array object set, then initialize the static array object, and allocate RAM space to the initialized static array object so that the first instance can use the RAM space.
[0069] It is understandable that the static array object extracted by the computer device from the static array object set has been pre-defined and can be used to provide shared data structures and resources when the application is instantiated. After extracting the static array object, the computer device can also perform initialization operations on it to ensure that the static array object is in a state that can be used. Since the actual data storage and operation of the static array object need to rely on RAM, the computer device can allocate appropriate RAM space for the initialized static array object as the memory area used when the first instance is running. In this way, each instance in a multi-application project can obtain sufficient RAM space support during operation, thereby improving the utilization rate of RAM resources and reducing the risk of instantiation failure due to insufficient memory.
[0070] Specifically, when the computer device initializes the static data object, it can first clear or reset the content of the static array object and configure the initial parameters to ensure that it does not contain any residual data or improper state, thereby preparing for the instantiation of the application. Through this initialization operation, the present application can ensure that each static array object can correctly support the current operation to be performed, further improving the utilization of RAM resources.
[0071] In one embodiment, in step S120, the pointer of the non-static array object is pointed to the target array object, and the data of the target array object is accessed by using the first instance, which may include:
[0072] S123: Assign the target array object to the non-static data object so that the non-static array object points to the RAM space of the target array object.
[0073] S124: Reference the non-static data object through the first instance to access data in the RAM space of the target array object.
[0074] In this embodiment, when a computer device uses a non-static array object to access data of a target array object, the target array object can be first assigned to the non-static data object so that the non-static array object points to the RAM space of the target array object, and then the non-static data object is referenced through the first instance to access data of the RAM space of the target array object.
[0075] It is understandable that, through the assignment operation, the computer device can point the pointer of the non-static array object to the RAM space of the target array object, so that they share the same memory area. Since the target array object is initialized and the RAM space is allocated by the static array object when the application is instantiated, the computer device can avoid repeated space allocation through this pointer mechanism, thereby allowing multiple instances to access the same memory area and reduce resource waste. When the pointer of the non-static array object points to the RAM space of the target array object, the first instance can directly access the data stored in the RAM space of the target array object through the non-static array object. In other words, any operation performed through the non-static array object, such as data reading, writing or modification, actually acts on the RAM space of the target array object.
[0076] In one embodiment, the method may further include:
[0077] S140: When any application package in the multi-application project includes multiple applications, determine a corresponding target array object to allocate to each application based on the static array object set.
[0078] In this embodiment, when instantiating an application in an application package, if there are multiple applications in the application package, facing each application, the computer device can extract any static array object from the static array object set in turn to initialize and allocate RAM space, and form a target array object corresponding to each application. Therefore, in the same application package, different application programs correspond to different target array objects.
[0079] It is understandable that each application in the same application package is independent of each other, and each has its own independent memory space and processing logic. Therefore, the computer device needs to provide independent memory space allocation for each application to ensure that each application can have independent RAM space and data storage structure, and will not interfere with each other or cause resource conflicts.
[0080] In one embodiment, the method may further include:
[0081] S150: When deleting an instance in a multi-application project, determining a target array object corresponding to the instance, and judging whether the instance is the last instance in the target array object.
[0082] S160: If yes, after the instance is deleted, the RAM space of the target array object is released to form a static array object, and the static array object is added to the static array object set.
[0083] S170: If not, directly delete the instance.
[0084] In this embodiment, when a user deletes a related instance of an application in a multi-application project in a computer device, the computer device can first determine the application where the instance is located and its corresponding target array object, and then determine whether the instance is the last instance in the target array object; if so, the computer device can release the RAM space of the target array object after the instance is deleted, form a static array object, and add the static array object to the static array object collection; if not, the computer device can directly delete the instance.
[0085] It is understandable that when the instance is not the last instance in the target array object, it means that the target array object is shared by multiple instances. After deleting the instance, there are still other instances using the target array object. Therefore, the computer device needs to retain the RAM space of the target array object for other still running instances to continue using. When the instance is the last instance in the target array object, it means that no other instance depends on the target array object. At this time, the computer device can release the RAM space associated with the target array object immediately after the instance is deleted and recycle it into the static array object collection to avoid unnecessary resource occupation.
[0086] In order to better explain the static object access method of this application, the following will be Figure 2 To further illustrate, schematically, Figure 2 As shown, Figure 2 A logical schematic diagram of a multi-application project provided in an embodiment of the present application.
[0087] Figure 2 In the example, the multi-application project includes a function package and three applet packages (application packages), namely package1, package 2 and package 3, each of which defines an applet (application). At this time, the computer device can define four array objects in the main class of the function package, including three static array objects ramBuffer1, ramBuffer2, ramBuffer3, and a non-static array object ramBuffer. The instantiation process of the application packages in the three applet packages is as follows:
[0088] 1. Instantiate applet1 in package1 to obtain instance1, and allocate space for instance1. At this time, for instance1, the status of the three static array objects in the function package is as follows: ramBuffer1 is empty, so RAM space is allocated for it, and the ramBuffer pointer points to this space, that is, ramBuffer = ramBuffer1, and ramBuffer2 and ramBuffer3 are both empty;
[0089] 2. Instantiate applet2 in package2 to obtain instance2, and allocate space for instance2. At this time, for instance2, the status of the three array objects in the function package is as follows: ramBuffer2 is empty, so RAM space is allocated for it, and the ramBuffer pointer points to this space, that is, ramBuffer = ramBuffer2, and ramBuffer1 and ramBuffer3 are both empty;
[0090] 3. Instantiate applet3 in package3 to obtain instance3, and allocate space for instance3. At this time, for instance3, the status of the three array objects in the function package is as follows: ramBuffer3 is empty, so RAM space is allocated for it, and the ramBuffer pointer points to this space, that is, ramBuffer = ramBuffer3, and ramBuffer1 and ramBuffer2 are both empty;
[0091] 4. Instantiate applet3 in package3 for the second time to obtain instance4. At this time, for instance3, the situation of the three array objects in the function package is as follows: at this time, ramBuffer3 is not empty, so the ramBuffer pointer is directly pointed to the space pointed to by ramBuffer3, that is, ramBuffer = ramBuffer3, and ramBuffer1 and ramBuffer2 are both empty.
[0092] In summary, in this multi-application project, references to ramBuffer1, ramBuffer2, and ramBuffer3 by each instantiated application can be implemented through ramBuffer.
[0093] The static object access device provided in an embodiment of the present application is described below. The static object access device described below and the static object access method described above can be referenced to each other.
[0094] In one embodiment, Figure 3 As shown, Figure 3 A schematic diagram of a static object access device provided in an embodiment of the present application; the present application also provides a static object access device, which is applied to a multi-application project, including a function package and multiple application packages. The device may include an object definition module 210, a first access module 220 and a second access module 230, which specifically include the following:
[0095] The object definition module 210 is used to define a static array object set and a non-static array object in a function package; wherein the static array object set includes a plurality of static array objects.
[0096] The first access module 220 is used to instantiate the applications in each application package to obtain a first instance, and extract a static array object from the static array object set to allocate space for the first instance to form a target array object of the application; point the pointer of the non-static array object to the target array object, and use the first instance to access data of the target array object.
[0097] The second access module 230 is used to determine the target array object of the application when the application in any application package is instantiated again to generate a second instance, so as to point the pointer of the non-static array object to the target array object and use the second instance to access data of the target array object.
[0098] In one embodiment, the object definition module 210 may include:
[0099] The total number determination submodule is used to determine the number of applications in each application package and summarize the total number of applications.
[0100] The collection definition submodule is used to define static array objects in the function package whose number corresponds to the total number of applications, forming a static array object collection.
[0101] In one embodiment, the first access module 220 may include:
[0102] The object initialization submodule is used to extract a static array object from the static array object set and initialize the static array object.
[0103] The space allocation submodule is used to allocate RAM space for the initialized static array object so that the first instance uses the RAM space.
[0104] In one embodiment, the first access module 220 may further include:
[0105] The object assignment submodule is used to assign the target array object to the non-static data object so that the non-static array object points to the RAM space of the target array object.
[0106] The data access submodule is used to reference the non-static data object through the first instance to perform data access to the RAM space of the target array object.
[0107] In one embodiment, the apparatus may further include:
[0108] The array object determination module is used to determine the corresponding target array object allocated to each application based on the static array object set when any application package in the multi-application project includes multiple applications; wherein the target array object of each application is different.
[0109] In one embodiment, the apparatus may further include:
[0110] The instance judgment module is used to determine the target array object corresponding to the instance when deleting the instance in a multi-application project, and to judge whether the instance is the last instance in the target array object.
[0111] The space release module is used to release the RAM space of the target array object when the instance is the last instance in the target array object, after the instance is deleted, to form a static array object, and to add the static array object to the static array object collection.
[0112] The instance deletion module is used to directly delete the instance when the instance is not the last instance in the target array object.
[0113] In one embodiment, the present application also provides a storage medium storing computer-readable instructions. When the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the static object access method as described in any of the above embodiments.
[0114] In one embodiment, the present application also provides a computer device having computer-readable instructions stored therein. When the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the static object access method as described in any one of the above embodiments.
[0115] Indicatively, Figure 4 As shown, Figure 4 This is a schematic diagram of the internal structure of a computer device provided in an embodiment of the present application. The computer device 300 may be provided as a server. Figure 4, the computer device 300 includes a processing component 302, which further includes one or more processors, and a memory resource represented by a memory 301, for storing instructions that can be executed by the processing component 302, such as an application. The application stored in the memory 301 may include one or more modules, each corresponding to a set of instructions. In addition, the processing component 302 is configured to execute instructions to perform the static object access method of any of the above embodiments.
[0116] The computer device 300 may further include a power supply component 303 configured to perform power management of the computer device 300, a wired or wireless network interface 304 configured to connect the computer device 300 to a network, and an input / output (I / O) interface 305. The computer device 300 may operate based on an operating system stored in the memory 301, such as Windows Server TM, Mac OS X TM, Unix TM, Linux TM, Free BSD TM, or the like.
[0117] Those skilled in the art will understand that Figure 4 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0118] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0119] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The various embodiments can be combined as needed, and the same or similar parts can refer to each other.
[0120] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A multi-instance static object access method, applied to multi-application projects, including a function package and multiple application packages, It is characterized in that The method comprises: A static array object set and a non-static array object are defined in the function package; wherein the static array object set includes a plurality of static array objects; For each application package, instantiate the application in the application package to obtain a first instance, and extract a static array object from the static array object set to allocate space for the first instance to form a target array object of the application; point the pointer of the non-static array object to the target array object, and use the first instance to access data of the target array object; When an application in any application package is instantiated again to generate a second instance, the target array object of the application is determined, the pointer of the non-static array object is pointed to the target array object, and the second instance is used to access data of the target array object.
2. The static object access method according to claim 1, It is characterized in that The static array object set is defined in the function package, including: Determine the number of applications in each application package and summarize them to obtain the total number of applications; In the function package, a number of static array objects corresponding to the total number of application programs is defined to form a static array object set.
3. The static object access method according to claim 1, It is characterized in that The step of extracting a static array object from the static array object set to allocate space for the first instance includes: Extracting a static array object from the static array object set, and initializing the static array object; A RAM space is allocated for the initialized static array object so that the first instance uses the RAM space.
4. The static object access method according to claim 1, It is characterized in that The step of pointing the pointer of the non-static array object to the target array object and using the first instance to perform data access on the target array object comprises: Assigning the target array object to the non-static data object so that the non-static array object points to the RAM space of the target array object; The non-static data object is referenced through the first instance to access data in the RAM space of the target array object.
5. The static object access method according to claim 1, It is characterized in that The method further comprises: When any application package in the multi-application project includes multiple applications, a corresponding target array object is determined for each application based on the static array object set; wherein the target array object of each application is different.
6. The static object access method according to claim 1, It is characterized in that The method further comprises: When deleting an instance in the multi-application project, determining a target array object corresponding to the instance, and judging whether the instance is the last instance in the target array object; If so, after the instance is deleted, the RAM space of the target array object is released to form a static array object, and the static array object is added to the static array object set; If not, the instance is deleted directly.
7. A static object access device, applied to a multi-application project, including a function package and multiple application packages, It is characterized in that The device comprises: An object definition module, used to define a static array object set and a non-static array object in the function package; wherein the static array object set includes a plurality of static array objects; A first access module is used to instantiate the application in each application package to obtain a first instance, and extract a static array object from the static array object set to allocate space to the first instance to form a target array object of the application; point the pointer of the non-static array object to the target array object, and use the first instance to access data of the target array object; The second access module is used to determine the target array object of the application when the application in any application package is instantiated again to generate a second instance, so as to point the pointer of the non-static array object to the target array object, and use the second instance to access data of the target array object.
8. The static object access device according to claim 7, It is characterized in that The object definition module includes: The total number determination submodule is used to determine the number of applications in each application package and summarize the total number of applications; The collection definition submodule is used to define static array objects in the function package whose number corresponds to the total number of application programs to form a static array object collection.
9. A storage medium, Features: The storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the static object access method according to any one of claims 1 to 6.
10. A computer device, It is characterized in that include: one or more processors, and memory; The memory stores computer-readable instructions, and when the computer-readable instructions are executed by the one or more processors, the steps of the static object access method according to any one of claims 1 to 6 are performed.
