CN113360343B - Method and device for analyzing memory occupation condition, storage medium and computer equipment - Google Patents

Method and device for analyzing memory occupation condition, storage medium and computer equipment Download PDF

Info

Publication number
CN113360343B
CN113360343B CN202110661596.XA CN202110661596A CN113360343B CN 113360343 B CN113360343 B CN 113360343B CN 202110661596 A CN202110661596 A CN 202110661596A CN 113360343 B CN113360343 B CN 113360343B
Authority
CN
China
Prior art keywords
objects
sub
stack
memory
preset number
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202110661596.XA
Other languages
Chinese (zh)
Other versions
CN113360343A (en
Inventor
张青阳
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Netease Hangzhou Network Co Ltd
Original Assignee
Netease Hangzhou Network Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Netease Hangzhou Network Co Ltd filed Critical Netease Hangzhou Network Co Ltd
Priority to CN202110661596.XA priority Critical patent/CN113360343B/en
Publication of CN113360343A publication Critical patent/CN113360343A/en
Application granted granted Critical
Publication of CN113360343B publication Critical patent/CN113360343B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3089Monitoring arrangements determined by the means or processing involved in sensing the monitored data, e.g. interfaces, connectors, sensors, probes, agents
    • G06F11/3096Monitoring arrangements determined by the means or processing involved in sensing the monitored data, e.g. interfaces, connectors, sensors, probes, agents wherein the means or processing minimize the use of computing system or of computing system component resources, e.g. non-intrusive monitoring which minimizes the probe effect: sniffing, intercepting, indirectly deriving the monitored data from other directly available data
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3003Monitoring arrangements specially adapted to the computing system or computing system component being monitored
    • G06F11/3037Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system component is a memory, e.g. virtual memory, cache
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3058Monitoring arrangements for monitoring environmental properties or parameters of the computing system or of the computing system component, e.g. monitoring of power, currents, temperature, humidity, position, vibrations

Abstract

The embodiment of the application discloses a method and a device for analyzing memory occupation conditions, a storage medium and computer equipment. The method comprises the following steps: acquiring a preset number of objects; when the game picture of the client is refreshed according to the preset frame rate, analyzing the memory occupation condition of a preset number of objects in the current frame duration corresponding to the preset frame rate; if the analysis of the memory occupation conditions of the preset number of objects is not completely finished in the current frame time length, the memory occupation conditions of the remaining objects in the preset number are analyzed in the subsequent frame time length of the current frame until the analysis of the memory occupation conditions of the preset number of objects is completely finished. According to the technical scheme, the memory occupation condition is analyzed when the game picture is refreshed, and the progress of the service client is not interrupted or killed, so that the fluency of the game picture of the client is not influenced.

Description

Method and device for analyzing memory occupation condition, storage medium and computer equipment
Technical Field
The present application relates to the field of computer software, and in particular, to a method, an apparatus, a storage medium, and a computer device for analyzing memory usage.
Background
In object-oriented software development, the occupation condition of a developer object to a memory must be clear, especially for a developer at a server side. Once memory leakage or other abnormality occurs, it is a disaster. With the increase of the operation time of the electronic game, the complexity and the code amount of the server code both increase sharply with the increase of the time, and the analysis of the occupation status of the online memory is one of the problems that are difficult to be solved in the industry.
In the prior art, when the memory occupation condition is analyzed, a process is usually connected to execute a memory analysis tool. However, the method for analyzing the memory occupation state in the prior art has the defect that during the analysis, the connected players of the process service cannot interact with the service end, and the game client is blocked or the process is killed.
Disclosure of Invention
The embodiment of the application provides a method, a device, a storage medium and computer equipment for analyzing memory occupation status, so that a client is prevented from being adversely affected during analysis.
The embodiment of the application provides a method for analyzing memory occupation status, which comprises the following steps:
acquiring a preset number of objects;
when the game picture of the client is refreshed according to a preset frame rate, analyzing the memory occupation condition of the preset number of objects within the current frame duration corresponding to the preset frame rate;
if the analysis of the memory occupation conditions of the preset number of objects is not completely finished in the current frame time length, analyzing the memory occupation conditions of the remaining objects in the preset number in the subsequent frame time length of the current frame until the analysis of the memory occupation conditions of the preset number of objects is completely finished.
Optionally, the analyzing the memory usage of the preset number of objects within the current frame duration corresponding to the preset frame rate includes: step S 1-1 : within the current frame duration of the preset frame rate, pressing n objects to the stack top of the stack, wherein the n objects are part of or all of the preset number of objects, and n is a natural number; step S 1-2 : popping a stack top object, wherein the stack top object is an object positioned at the stack top of the stack; step S 1-3 : and calling a preset function, and calculating n objects popped out from the stack top, the memory of any one of the sub-objects of the n objects, and the sum of the memory of any one of the sub-objects of the n objects and the memory of the sub-objects of the n objects one by one.
Optionally, the pushing n objects to the top of the stack within the current frame duration of the preset frame rate includes: initializing a given queue to obtain an initialized queue; storing each object and its sub-objects in the n objects into the initialized queue; and pushing a head object of the initialized queue to the top of the stack while storing each object and the sub-objects thereof in the n objects into the initialized queue until the initialized queue is empty again.
Optionally, the storing each of the n objects and its child objects into the initialized queue includes: for object O of any tree structure in the n objects i The object O is i Storing the self as a root node into the initialized queue; when the object O is i De-queuing the object O from the initialized queue i The sub-objects are stored in the initialized queue according to the following first principle: 1) the object O i The sub-objects which are closer to the root node in all the sub-objects are stored in the initialized queue first(ii) a 2) The object of the same level in the tree structure is stored into the initialized queue first, and the sub-objects are also stored into the initialized queue first; when the object O is i Any one of the sub-objects O of ij Dequeuing the child object O from the initialized queue ij The sub-objects are stored in the initialized queue according to the following second principle: 1) the sub-object O ij As the sub-object O ij Parent node of all children, said children O ij The child objects which are closer to the parent node in all the child objects are stored in the initialized queue first; 2) the object of the same layer below the father node is stored into the initialized queue first, and the child object is stored into the initialized queue first.
Optionally, the analyzing the memory usage of the preset number of objects within the current frame duration corresponding to the preset frame rate includes: step S 2-1 : within the current frame duration of the preset frame rate, pressing n objects to the stack top of the stack, wherein the n objects are part of or all of the preset number of objects, and n is a natural number; step S 2-2 : reading a stack top object, wherein the stack top object is an object positioned at the stack top of the stack; step S 2-3 : and analyzing the memory occupation condition of the preset number of objects by performing re-operation on the stack top according to whether the sub-objects of the stack top object have been calculated by the memory.
Optionally, analyzing the memory occupation of the preset number of objects by performing a re-operation on the stack top according to whether the memory of the sub-object of the stack top object has been calculated includes: step S 3-1 : if the sub-object of the stack top object is already calculated in the memory or the stack top object does not have the sub-object, calculating the memory of the stack top object of which the sub-object is already calculated in the memory; step S 3-2 : if the sub-object of the stack top object has not been calculated in the memory, pressing the sub-object of the stack top object whose sub-object has not been calculated in the memory to the stack top, and the flow goes to the above step S 2-2 Until the stack top is pressedAnd completely analyzing the memory occupation conditions of the n objects.
Optionally, if the analysis of the memory usage of the preset number of objects is not completely completed within the current frame time, the analyzing of the memory usage of the remaining objects in the preset number within the subsequent frame time of the current frame until the analysis of the memory usage of the preset number of objects is completely completed includes: step S 4-1 : if the n objects pressed into the stack top in the current frame duration of the preset frame rate are part of the objects in the preset number, pressing the rest objects in the preset number into the stack top in the next frame duration of the current frame; step S 4-2 : if the preset number of objects are all pressed into the stack top within the next frame duration of the current frame, the process goes to step S 1-2 To step S 1-3 Or step S 2-2 To step S 2-3 Otherwise, the flow goes to step S 4-1 Until all the objects with the preset number are pressed into the stack top; repeating the above step S 4-1 To step S 4-2 And analyzing the memory occupation condition of the preset number of objects until the analysis is completely finished.
An embodiment of the present application further provides a device for analyzing memory usage, including:
the object acquisition module is used for acquiring a preset number of objects;
the first analysis module is used for analyzing the memory occupation condition of the preset number of objects within the current frame duration corresponding to the preset frame rate when the game screen of the client is refreshed according to the preset frame rate;
and a second analysis module, configured to, if the analysis of the memory usage of the preset number of objects is not completely completed within the current frame time, analyze the memory usage of the remaining objects in the preset number within a subsequent frame time of the current frame until the analysis of the memory usage of the preset number of objects is completely completed.
An embodiment of the present application further provides a computer-readable storage medium, where a computer program is stored, where the computer program is suitable for a processor to execute loading so as to execute the steps in the method for analyzing a memory usage status according to any of the above embodiments.
An embodiment of the present application further provides a computer device, where the computer device includes a storage and a processor, where the storage stores a computer program, and the processor executes, by calling the computer program stored in the storage, the steps in the method for analyzing the memory usage status according to any of the above embodiments.
According to the technical scheme provided by the embodiment of the application, when the server refreshes the game picture of the client according to the preset frame rate, the memory occupation conditions of the preset number of objects are analyzed in the current frame time corresponding to the preset frame rate, the analysis on the memory occupation conditions of the preset number of objects is not completely completed in the current frame time, the memory occupation conditions of the rest objects in the preset number are continuously analyzed in the subsequent frame time of the current frame, and the network game has the logic of framing, so that the memory occupation conditions are analyzed when the game picture is refreshed, the process of the server is not interrupted or killed, and the fluency degree of the game picture of the client is not influenced.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1 is a system diagram illustrating an apparatus for analyzing memory usage according to an embodiment of the present disclosure.
Fig. 2 is a flowchart illustrating a method for analyzing a memory usage status according to an embodiment of the present disclosure.
Fig. 3 is a schematic diagram of an object of a tree structure provided in an embodiment of the present application.
Fig. 4 is a schematic diagram of an object of a tree structure according to another embodiment of the present application.
Fig. 5a to 5e are schematic diagrams of an object and its child objects for enqueuing and popping, according to an embodiment of the present application.
Fig. 6a to 6j are schematic diagrams illustrating analysis of memory usage by popping an object and its child objects out of the top of a stack according to an embodiment of the present application.
Fig. 7a to 7n are schematic diagrams illustrating analysis of memory usage by pushing and popping an object and its children objects onto and off the top of a stack according to an embodiment of the present application.
Fig. 8 is a schematic structural diagram of an apparatus for analyzing a memory usage status according to an embodiment of the present disclosure.
Fig. 9 is a schematic structural diagram of a computer device according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The embodiment of the application provides a method and a device for analyzing memory occupation status, a storage medium and computer equipment. Specifically, the method for analyzing the memory usage status according to the embodiment of the present application may be executed by a computer device, where the computer device may be a terminal or a server. The terminal may be a terminal device such as a smart phone, a tablet Computer, a notebook Computer, a touch screen, a game machine, a Personal Computer (PC), a Personal Digital Assistant (PDA), and the like, and may further include a client, which may be a game application client, a browser client carrying a game program, or an instant messaging client, and the like. The server may be an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, or a cloud server providing basic cloud computing services such as cloud service, a cloud database, cloud computing, a cloud function, cloud storage, network service, cloud communication, middleware service, domain name service, security service, CDN, and a big data and artificial intelligence platform.
For example, when the method for analyzing the memory usage is executed in a terminal, a game application is stored in the terminal device and used for presenting a virtual scene in a game screen. The terminal device is used for interacting with a user through a graphical user interface, for example, downloading and installing a game application program through the terminal device and running the game application program. The manner in which the terminal device provides the graphical user interface to the user may include a variety of ways, for example, the graphical user interface may be rendered for display on a display screen of the terminal device or presented by holographic projection. For example, the terminal device may include a touch display screen for presenting a graphical user interface including a game screen and receiving operation instructions generated by a user acting on the graphical user interface, and a processor for executing the game, generating the graphical user interface, responding to the operation instructions, and controlling display of the graphical user interface on the touch display screen.
For example, when the method for analyzing the memory usage runs on a server, the method may be a cloud game. Cloud gaming refers to a gaming regime based on cloud computing. In the cloud game running mode, the running main body of the game application program and the game picture presenting main body are separated, and the storage and running of the method for analyzing the memory occupation condition are completed on the cloud game server. The game screen presentation is performed at a cloud game client, which is mainly used for receiving and sending game data and presenting the game screen, for example, the cloud game client may be a display device with a data transmission function near a user side, such as a mobile terminal, a television, a computer, a palm computer, a personal digital assistant, and the like, but a terminal device for performing game data processing is a cloud game server at the cloud end. When a game is played, a user operates the cloud game client to send an operation instruction to the cloud game server, the cloud game server runs the game according to the operation instruction, data such as game pictures and the like are encoded and compressed, the data are returned to the cloud game client through a network, and finally the data are decoded through the cloud game client and the game pictures are output.
Referring to fig. 1, fig. 1 is a system diagram illustrating an apparatus for analyzing memory usage according to an embodiment of the present disclosure. The system may include at least one terminal 1000, at least one server 2000, at least one database 3000, and a network 4000. The terminal 1000 held by the user can be connected to servers of different games through the network 4000. Terminal 1000 can be any device having computing hardware capable of supporting and executing a software product corresponding to a game. In addition, terminal 1000 can have one or more multi-touch sensitive screens for sensing and obtaining user input through touch or slide operations performed at multiple points on one or more touch sensitive display screens. In addition, when the system includes a plurality of terminals 1000, a plurality of servers 2000, and a plurality of networks 4000, different terminals 1000 may be connected to each other through different networks 4000 and through different servers 2000. The network 4000 may be a wireless network or a wired network, such as a Wireless Local Area Network (WLAN), a Local Area Network (LAN), a cellular network, a 2G network, a 3G network, a 4G network, a 5G network, and so on. In addition, different terminals 1000 may be connected to other terminals or a server using their own bluetooth network or hotspot network. For example, a plurality of users may be online through different terminals 1000 to be connected and synchronized with each other through a suitable network to support multiplayer games. In addition, the system may include a plurality of databases 3000, the plurality of databases 3000 being coupled to different servers 2000, and information related to the game environment may be continuously stored in the databases 3000 when different users play the multiplayer game online.
The embodiment of the application provides a method for analyzing memory occupation status, which can be executed by a terminal or a server. The embodiment of the present application is described with a method for analyzing a memory usage status performed by a terminal as an example. The terminal comprises a touch display screen and a processor, wherein the touch display screen is used for presenting a graphical user interface and receiving an operation instruction generated by a user acting on the graphical user interface. When a user operates the graphical user interface through the touch display screen, the graphical user interface can control the local content of the terminal through responding to the received operation instruction, and can also control the content of the opposite-end server through responding to the received operation instruction. For example, the operation instruction generated by the user acting on the graphical user interface comprises an instruction for starting a game application, and the processor is configured to start the game application after receiving the instruction provided by the user for starting the game application. Further, the processor is configured to render and draw a graphical user interface associated with the game on the touch display screen. A touch display screen is a multi-touch sensitive screen capable of sensing a touch or slide operation performed at a plurality of points on the screen at the same time. The user uses a finger to perform touch operation on the graphical user interface, and when the graphical user interface detects the touch operation, different virtual objects in the graphical user interface of the game are controlled to perform actions corresponding to the touch operation. For example, the game may be any one of a leisure game, an action game, a role playing game, a strategy game, a sports game, an educational game, and the like. Wherein the game may comprise a virtual scene of the game drawn on a graphical user interface. Further, one or more virtual objects, such as virtual characters, controlled by the user (or player) may be included in the virtual scene of the game. Additionally, one or more obstacles, such as railings, ravines, walls, etc., may also be included in the virtual scene of the game to limit movement of the virtual objects, e.g., to limit movement of one or more objects to a particular area within the virtual scene. Optionally, the virtual scene of the game also includes one or more elements, such as skills, points, character health, energy, etc., to provide assistance to the player, provide virtual services, increase points related to player performance, etc. In addition, the graphical user interface may also present one or more indicators to provide instructional information to the player. For example, a game may include a player-controlled virtual object and one or more other virtual objects (such as enemy characters). In one embodiment, one or more other virtual objects are controlled by other players of the game. For example, one or more other virtual objects may be computer controlled, such as a robot using Artificial Intelligence (AI) algorithms, to implement a human-machine fight mode. For example, the virtual objects possess various skills or capabilities that the game player uses to achieve the goal. For example, the virtual object possesses one or more weapons, props, tools, etc. that may be used to eliminate other objects from the game. Such skills or capabilities may be activated by a player of the game using one of a plurality of preset touch operations with a touch display screen of the terminal. The processor may be configured to present a corresponding game screen in response to an operation instruction generated by a touch operation of a user.
Please refer to fig. 2, which is a flowchart illustrating a method for analyzing memory usage according to an embodiment of the present disclosure. Fig. 2 is a diagram for describing the technical solution of the present application with a first game server as an execution subject, wherein the first game server is a server that runs a first game. The method illustrated in fig. 2 mainly includes steps S201 to S203, and is described in detail as follows:
in step S201, a preset number of objects are acquired.
In the embodiment of the present application, the preset number of objects refers to a certain number of objects, and the objects are targets to be subjected to memory occupation analysis subsequently. Acquiring the preset number of objects not only acquires the objects themselves, but also acquires the relationships between the objects and the sub-objects thereof. Fig. 3 is a schematic diagram of relationships between objects and their sub-objects provided in the embodiment of the present application, and it can be seen that the relationships between these objects and their sub-objects are like a tree structure.
Step S202, when the game picture of the client is refreshed according to the preset frame rate, the memory occupation conditions of the preset number of objects are analyzed within the duration of the current frame corresponding to the preset frame rate.
The frame rate of the game screen may be represented by a Frame Per Second (FPS) of the game screen, and an inverse of the frame rate is a duration of one frame, that is, a duration of time that the server refreshes the game screen of the client. Because the network game based on the C/S architecture has the framing logic, when the server refreshes the game picture of the client according to the preset frame rate, the memory occupation conditions of the preset number of objects are analyzed in the current frame duration corresponding to the preset frame rate, and the fluency of the game picture presented at the client cannot be influenced.
As an embodiment of the present application, the step S of analyzing the memory usage of the preset number of objects within the current frame duration corresponding to the preset frame rate may be performed 1-1 To step S 1-3 The realization is as follows:
step S 1-1 : and within the current frame duration corresponding to the preset frame rate, pressing n objects to the stack top of the stack, wherein the n objects are part or all of preset number of objects, and n is a natural number.
Since the duration of a frame is limited, and the preset number may be a larger number or a smaller number, all objects of the preset number may be pushed to the top of the stack within the duration of a frame, or only part of the objects may be pushed to the top of the stack. When the n objects pushed onto the stack top are the preset number of partial objects, the objects need to be continuously pushed onto the stack top within the duration of the next frame of the current frame, at this time, the process will be executed by step S203, which will be described in detail later.
Specifically, in an embodiment of the present application, in a duration of a current frame corresponding to a preset frame rate, the following step S may be performed to push n objects onto a stack top of a stack 1-1-1 To step S 1-1-3 The realization is as follows:
step S 1-1-1 : initializing a given queue, resulting in an initialized queue.
In the present embodiment, a given queue is initialized, and the resulting initialized queue is empty.
Step S 1-1-2 : and storing each object and the sub-objects thereof in the initialized queue.
As a logical structure of First-In First-Out (FIFO), the operation of Queue (Queue) is performed at the head and tail of the Queue, wherein when an object is to be enqueued, it is stored from the tail of the Queue, and when an object is to be dequeued, it is fetched from the head of the Queue. Thus, storing each of the n objects and its children into the initialized queue is from the tail of the queueIn terms of this, it may be: for any one tree-structured object O among n objects i To the object O i Storing the self as a root node into an initialized queue; when the object O i Dequeuing itself from the initialized queue, object O i The child objects are stored in the initialized queue according to the following first principle: 1) object O i The sub-objects which are closer to the root node in all the sub-objects are stored into the initialized queue first; 2) the more the objects in the same level in the tree structure are stored in the initialized queue, the more the child objects are stored in the initialized queue; when the object O i Any one of the sub-objects O of ij Dequeuing from the initialized queue, child O ij The sub-objects are stored into the initialized queue according to the following second principle: 1) will sub-object O ij As a sub-object O ij Parent node of all child objects, child object O ij The child objects which are closer to the parent node in all the child objects are stored in the initialized queue first; 2) the object in the same layer under the father node is stored in the initialized queue first, and the child object is stored in the initialized queue first.
Step S 1-1-3 : and pushing the head object of the initialized queue to the top of the stack while storing each object and the child objects thereof in the n objects in the initialized queue until the initialized queue is empty again.
On the one hand, since when the object O i Object O dequeues itself from the initialized queue i The sub-objects closer to the root node among all the sub-objects are stored in the initialized queue first, and the objects in the same level in the tree structure are stored in the initialized queue first, and the sub-objects are also stored in the initialized queue first, or the sub-object O ij The child objects closer to the parent node among all the child objects are stored in the initialized queue first, and the objects in the same level below the parent node are stored in the initialized queue first, and the child objects are stored in the initialized queue first, so that the object O is stored in the initialized queue simultaneously with the storage of each of the n objects and the child objects thereof i The closer the child object is to the root node, of all the child objects, the earlier the child object is pushed to the top of the stack, andthe earlier an object at the same level in the tree structure is stored in the initialized queue, the earlier its child object is pushed to the top of the stack, or, the child object O ij The child objects which are closer to the father node in all the child objects are pressed onto the stack top first, and the objects on the same layer below the father node are stored into the initialized queue first, and the child objects are pressed onto the stack top first; on the other hand, while each object of the n objects and its children are stored in the initialized queue, the head object of the initialized queue is pushed to the top of the stack, so that the initialized queue is a process in which objects (including children) are increased and then a process in which objects (including children) are decreased, when the initialized queue is empty again, the number of objects in the stack reaches a maximum value, the top object is the child object of the lowest layer in the tree structure object, and the child object is the child object of the last layer in the lowest layer in which the initialized queue is stored.
Step S 1-2 : and popping a top stack object, wherein the top stack object is an object positioned at the top of the stack.
As mentioned above, when the initialized queue is empty again, the top-of-stack object is the lowest layer of the tree structure object and the last child object stored in the initialized queue; since the stack belongs to a First-In Last-Out (FILO) logical structure, object O i The sub-object closer to the root node among all the sub-objects is pushed to the top of the stack first, and the object of the same level in the tree structure is stored into the initialized queue first, and the sub-object is also pushed to the top of the stack first, or the sub-object O ij The child objects which are closer to the parent node in all the child objects are pushed to the top of the stack first, and the objects of the same layer below the parent node are stored in the initialized queue first, and the child objects are also pushed to the top of the stack first, so that when the objects are continuously popped from the top of the stack until the stack is empty, a complete backtracking is performed on the objects in the stack.
Step S 1-3 : and calling a preset function, and calculating the memory of n objects popped from the stack top, any one sub-object of the n objects, and the sum of the memory of any one sub-object of the n objects and the sub-object thereof one by one.
In the embodiment of the present application, the preset function may be a built-in function of a computation memory provided by a compiler of an object-oriented programming language. When an object or a sub-object is popped from the top of the stack, the built-in function can be called once, so that the calculation of the memories of a single object and each sub-object thereof can be completed, and the memories can be accumulated to obtain the sum of the memories of the objects and the sub-objects thereof.
To explain the above step S 1-1 To step S 1-3 The following takes the tree-structured object a illustrated in fig. 4 as an example, and the following is described:
when a given queue is initialized, an empty initialized queue is obtained, and the stack is also an empty stack. When the object a of the n objects is stored as the root node in the initialized queue, it becomes the head of queue object, and the stack is still an empty stack, as shown in fig. 5 a. Thereafter, as the head-of-queue object A is dequeued, the child objects of object A are stored in the initialized queue. Since the sub-object a, the sub-object b, the sub-object c, and the sub-object d are closer to the object a, which is the root node, than to the sub-object a1, the sub-object a2, the sub-object b1, the sub-object b2, and the sub-object b3, the sub-object a, the sub-object b, the sub-object c, and the sub-object d are stored in the initialized queue before the sub-object a1, the sub-object a2, the sub-object b1, the sub-object b2, and the sub-object b3, at this time, the dequeued head-of-line object a is pushed to the top of the stack and is stored in succession into the sub-object a, the sub-object b, the sub-object c, and the sub-object d of the initialized queue, with the sub-object a becoming the head-of-line object, as shown in fig. 5 b. It should be noted here that, the sub-object a, the sub-object b, the sub-object c, and the sub-object d are not in strict order when stored in the initialized queue, for example, the sub-object d may be listed first, the sub-object c may be listed second, the sub-object b may be listed next to the sub-object c, and the sub-object a may be listed last. With respect to FIG. 5b, the head of line object at this time is child object a. When child a is dequeued and pushed to the top of the stack, child a1 and child a2 for child a are stored in the initialized queue, at which time child b becomes the head of line object, as shown in FIG. 5 c. As the child b dequeues and pushes to the top of the stack, the child b1, child b2, and child b3 are stored in the initialized queue one after the other. It should be noted that, although the sub-object a1, the sub-object a2, the sub-object b1, the sub-object b2 and the sub-object b3 are all stored in the initialized queue, since the sub-object a and the sub-object b belong to the same level of the tree structure, and the sub-object a is stored in the initialized queue before the sub-object b, the sub-object a1 and the sub-object a2 of the sub-object a are stored in the initialized queue before the sub-object b1, the sub-object b2 and the sub-object b3 of the sub-object b; the initialized queue and stack status after dequeuing and pushing child b onto the top of the stack is shown in FIG. 5 d. After that, the objects in the initialized queue are dequeued and pushed to the top of the stack, both following strictly the first principle and the second principle mentioned in the previous embodiments. When the initialized queue is empty again, object a and its children are stored in the stack, at which time the number of objects in the stack reaches a maximum, and the top object of the stack is the lowest layer of tree structure object a in the example of fig. 4 and the last one is stored in the initialized queue's children b3, as shown in fig. 5 e.
For the stack illustrated in fig. 5e, when the child object b3 is popped from the top of the stack, a preset function is called to calculate the memory of the stack, the preset function is called, assuming that the calculated memory occupied by the child object b3 is 8 bytes, and after the child object b3 is popped from the top of the stack illustrated in fig. 5e, the state of the stack and the result of analyzing the memory occupied by the child object b3 are shown in fig. 6 a. For the stack illustrated in fig. 6a, when the sub-object b2 is popped from the top of the stack, a preset function is called to calculate the memory of the stack, the preset function is called, assuming that the calculated memory occupied by the sub-object b2 is 15 bytes, and after the sub-object b2 is popped from the top of the stack illustrated in fig. 6a, the state of the stack and the result of analyzing the memory occupied by the sub-object b2 are shown in fig. 6 b. For the stack illustrated in fig. 6b, when the child object b1 is popped from the top of the stack, a preset function is called to calculate the memory of the stack, the preset function is called, assuming that the calculated memory occupied by the child object b1 is 10 bytes, and after the child object b1 is popped from the top of the stack illustrated in fig. 6b, the state of the stack and the result of analyzing the memory occupied by the child object b1 are shown in fig. 6 c. As can be seen from fig. 6c, the results of the memory usage analysis of the sub-object b1, the sub-object b2, and the sub-object b3 of the sub-object b are 10 bytes, 15 bytes, and 8 bytes, respectively, and the results are accumulated to obtain that the sum of the memory usage of all the sub-objects of the sub-object b is 33 bytes.
For the stack illustrated in fig. 6c, when the sub-object a2 of the sub-object a is popped from the top of the stack, a preset function is called to calculate the memory of the stack, the preset function is called, and assuming that the calculated memory occupied by the sub-object a2 is 8 bytes, after the sub-object a2 is popped from the top of the stack illustrated in fig. 6c, the state of the stack and the result of the memory occupation analysis of the sub-object a2 are shown in fig. 6 d. For the stack illustrated in FIG. 6d, when the sub-object a1 of the sub-object a is popped from the top of the stack, the preset function is called to calculate the memory, the preset function is called, and assuming that the calculated memory occupied by the sub-object a1 is 9 bytes, and after the sub-object a1 is popped from the top of the stack illustrated in FIG. 6d, the state of the stack and the result of the memory occupation analysis of the sub-object a1 are shown in FIG. 6 e. As can be seen from fig. 6e, the results of the memory usage analysis of the sub-object a2 and the sub-object a1 of the sub-object a are respectively 8 bytes and 9 bytes, and the sum of the memory usage of all the sub-objects of the sub-object a is 17 bytes. It should be noted that, because the sub-object a is not yet popped from the stack at this time, the memory occupancy status of the sub-object a is still unknown, and the memory occupancy status of the sub-object of the object a is still 33 bytes.
For the stack illustrated in fig. 6e, when the sub-object d is popped from the stack top, the preset function is called to calculate the memory of the stack, the preset function is called, it is assumed that the calculated memory occupied by the sub-object d is 10 bytes, and after the sub-object d is popped from the stack top of the stack illustrated in fig. 6e, the stack status and the memory occupation analysis result of the sub-object d are shown in fig. 6 f. Since the sub-object d is popped from the stack at this time, the memory usage status of the object a, that is, the memory usage status of the sub-object d, is 10 bytes.
For the stack illustrated in fig. 6f, when the child object c is popped from the stack top, the preset function is called to calculate the memory of the child object c, the preset function is called, it is assumed that the calculated memory occupied by the child object c is 9 bytes, and after the child object c is popped from the stack top of the stack illustrated in fig. 6f, the stack status and the memory occupation analysis result of the child object c are shown in fig. 6 g. Since the sub-object c is popped from the stack at this time, the memory usage status of the object a, that is, the sum of the memory usage of the sub-object d and the memory usage of the sub-object c, that is, the memory of the sub-object of the object a is 19 bytes at this time.
For the stack illustrated in fig. 6g, when the sub-object b is popped from the stack top, the preset function is called to calculate the memory of the stack, the preset function is called, it is assumed that the calculated memory occupied by the sub-object b is 12 bytes, and after the sub-object b is popped from the stack top of the stack illustrated in fig. 6g, the stack status and the memory occupation analysis result of the sub-object b are illustrated in fig. 6 h. Since the sub-object b and its sub-object b1, the sub-object b2, and the sub-object b3 are all popped from the stack at this time, the memory usage status of the object a is the sum of the memory usage of the sub-object d, the sub-object c, the sub-object b and its sub-object b1, the sub-object b2, and the sub-object b3, that is, the memory of the object a is 64 bytes at this time.
For the stack illustrated in fig. 6h, when the sub-object a is popped from the stack top, the preset function is called to calculate the memory of the stack, the preset function is called, it is assumed that the calculated memory occupied by the sub-object a is 11 bytes, and after the sub-object a is popped from the stack top of the stack illustrated in fig. 6h, the stack status and the memory occupation analysis result of the sub-object a are shown in fig. 6 i. Since the sub-object a and its sub-object a1 and sub-object a2 have been popped from the stack at this time, the memory usage status of the object a is the sum of the memory usage of the sub-object d, c, b and its sub-object b1, b2 and its sub-object b3, and a and its sub-object a1 and its sub-object a2, that is, the memory of the object a is 92 bytes at this time.
For the stack illustrated in fig. 6i, when the object a is popped from the stack top, the preset function is called to calculate the memory of the object a, the preset function is called, assuming that the calculated memory occupied by the object a is 20 bytes, and after the object a is popped from the stack top of the stack illustrated in fig. 6i, the stack status and the memory occupation analysis result of the object a are as illustrated in fig. 6j, that is, the stack is changed to an empty stack again. Since the object A and its child objects are popped from the stack at this time, the memory usage status of the object A is the sum of the memory usage of the object A itself, the child object d, the child object c, the child object b, the child object a, the child object b1, the child object b2, the child object b3, the child object a1, and the child object a2, that is, the memory of the object A is 112 bytes at this time.
As another embodiment of the present application, the step S of analyzing the memory usage of the preset number of objects within the duration of the current frame corresponding to the preset frame rate may be performed 2-1 To step S 2-3 The realization is as follows:
step S 2-1 : within the current frame duration of a preset frame rate, n objects are pressed to the stack top of a stack, wherein the n objects are part or all of preset number of objects, and n is a natural number.
Different from the foregoing embodiment, in which a stack is combined with a queue to analyze the memory occupation of an object, in this embodiment, no combination of queues is required, and only one stack is used to push n objects one by one onto the top of the stack within the current frame duration of the preset frame rate.
Step S 2-2 : and reading a top stack object, wherein the top stack object is an object positioned at the top of the stack.
Reading the stack top object to determine whether the stack top object passes through the step S 2-1 Whether the child objects of the object pushed to the top of the stack have already been computed from memory. At this time, reading the top object includes not only popping up the object from the top but also reading the information such as the sub-object inclusion status of the top object recorded in the dictionary from the dictionary and whether or not the memory of the sub-object is calculated.
Step S 2-3 : and analyzing the memory occupation condition of the preset number of objects by carrying out re-operation on the stack top according to the condition of the stack top object or whether the memory of the sub-objects of the stack top object is already calculated.
Specifically, step S 2-3 Comprises the following step S 3-1 And step S 3-2
Step S 3-1 : if the sub-object of the top stack object is already calculated in the memory or the top stack object does not have the sub-object, calculating the memory of the top stack object in which the sub-object does not exist or the top stack object in which the sub-object is already calculated in the memory.
As described above, in the embodiment of the present application, the dictionary records whether a sub-object exists in a top-of-stack object and/or whether the sub-object is already calculated in the memory. And reading the dictionary record, and if the sub-object of the top stack object is already calculated in the memory or the top stack object does not have the sub-object, directly calculating the memory of the top stack object which does not have the sub-object or the top stack object of which the sub-object is already calculated in the memory.
Step S 3-2 : if the sub-object of the top object has not been calculated in the memory, then the sub-object of the top object whose sub-object has not been calculated in the memory is pressed into the top of the stack, and the flow goes to the above step S 2-2 And until the memory occupation conditions of the n objects pressed into the stack top are completely analyzed.
Still taking the object A of the tree structure illustrated in FIG. 4 as an example, the step S in the above embodiment will be described 2-1 To step S 2-3 The technical scheme is as follows:
first, object A itself is pushed to the top of the stack, and at this point the state of the stack is as shown in FIG. 7a, with the top object being object A itself. Then, object a is read from the dictionary. According to the result of the dictionary record, the sub-object a, the sub-object b, the sub-object c and the sub-object d of the object a have not been calculated yet, so the sub-object a, the sub-object b, the sub-object c and the sub-object d of the object a are sequentially pushed onto the stack, the state of the stack is shown in fig. 7b, and the top object of the stack is the sub-object d. Then, reading the record result of the top object, i.e. the sub-object d, from the dictionary, and according to the record result of the dictionary, the sub-object d has no sub-object, so that the memory occupation situation is directly calculated when the sub-object d is popped up, and it is assumed that the calculation result is that the sub-object d occupies 10 bytes of memory. After the sub-object d is popped from the stack illustrated in fig. 7b, the stack status and the result of analyzing the memory usage of the sub-object d are shown in fig. 7 c.
For the stack illustrated in fig. 7c, the recording result of the top object, i.e., the sub-object c, is read from the dictionary, and the sub-object c does not have a sub-object according to the recording result of the dictionary, so that when the sub-object c is popped from the top of the stack illustrated in fig. 7c, a preset function is called to directly calculate the memory of the sub-object c, and it is assumed that the memory occupied by the sub-object c is 9 bytes after calculation, and the state of the stack and the memory occupation analysis result of the sub-object c are shown in fig. 7d after the sub-object c is popped from the top of the stack illustrated in fig. 7 c.
For the stack illustrated in FIG. 7d, the recorded result of the top object, i.e. the sub-object b, is read from the dictionary, and according to the recorded result of the dictionary, the sub-object b1, the sub-object b2 and the sub-object b3 of the sub-object b are not calculated in the memory. Therefore, the sub-object b1, the sub-object b2, and the sub-object b3 of the sub-object b need to be pushed into the stack illustrated in FIG. 7d in turn, and the resulting stack is shown in FIG. 7 e.
For the stack illustrated in fig. 7e, the recording result of the top object, i.e. the sub-object b3, is read from the dictionary, and the sub-object b3 has no sub-object according to the recording result of the dictionary, so that when the sub-object b3 is popped from the top of the stack illustrated in fig. 7e, a preset function is called to directly calculate the memory thereof; assuming that the memory occupied by the sub-object b3 is 8 bytes, the stack status and the memory occupation analysis result of the sub-object b3 after the sub-object b3 is popped from the top of the stack shown in FIG. 7e are shown in FIG. 7 f. For sub-object b1 and sub-object b2, the processing is similar as sub-object b 3. After processing the sub-object b3, the state of the stack and the result of the memory usage analysis of the sub-object b2 and the state of the stack and the result of the memory usage analysis of the sub-object b1 are shown in fig. 7g and fig. 7h, the memory usage of the sub-object b1 and the sub-object b2 is 10 bytes and 15 bytes, respectively, and the sum of the memory usage of the sub-object b1, the sub-object b2 and the sub-object b3 of the sub-object b is 33 bytes.
For the stack illustrated in fig. 7h, the recorded result of the top object, i.e., the sub-object b, is read from the dictionary, and according to the recorded result of the dictionary, the sub-object b1, the sub-object b2, and the sub-object b3 of the sub-object b have been already calculated in memory, so when the sub-object b is popped from the top of the stack illustrated in fig. 7h, a preset function is called to directly calculate the memory thereof, and assuming that the calculated memory occupied by the sub-object b itself is 12 bytes, after the sub-object b is popped from the top of the stack illustrated in fig. 7h, the state of the stack and the result of analyzing the memory occupied by the sub-object b are illustrated in fig. 7 i.
For the stack illustrated in fig. 7i, the recording result of the top object, i.e. the sub-object a, is read from the dictionary, and the sub-object a1 and the sub-object a2 of the sub-object a are not calculated in the memory according to the recording result of the dictionary. Therefore, the sub-object a1 and the sub-object a2 of the sub-object a need to be pushed to the stack illustrated in FIG. 7i in turn, and the resulting stack is shown in FIG. 7 j.
For the stack illustrated in fig. 7j, the recording result of the top object, i.e., the sub-object a2, is read from the dictionary, and the sub-object a2 does not have a sub-object according to the recording result of the dictionary, so that when the sub-object a2 is popped from the top of the stack illustrated in fig. 7j, a preset function is called to directly calculate the memory thereof; assuming that the memory occupied by the sub-object a2 is 8 bytes, the stack status and the memory occupation analysis result of the sub-object a2 are shown in FIG. 7k after the sub-object a2 is popped from the top of the stack shown in FIG. 7 j. For the sub-object a1, the processing method is similar to that of the sub-object a2, and the stack status and the memory usage analysis result of the sub-object a1 after the sub-object a1 is processed are shown in fig. 7 l.
For the stack illustrated in fig. 7l, the recording result of the top object, i.e., the sub-object a, is read from the dictionary, and according to the recording result of the dictionary, both the sub-object a1 and the sub-object a2 of the sub-object a have been already calculated in memory, so when the sub-object a is popped from the top of the stack illustrated in fig. 7l, a preset function is called to directly calculate the memory thereof, and assuming that the memory occupied by the sub-object a itself is 11 bytes after calculation, the state of the stack and the result of analyzing the memory occupied by the sub-object a are as illustrated in fig. 7m after the sub-object a is popped from the top of the stack illustrated in fig. 7 l.
For the stack illustrated in fig. 7m, the recording result of the top object, i.e., the object a, is read from the dictionary, and the memory of all the sub-objects of the object a has been already calculated according to the recording result of the dictionary, so that when the sub-object a is popped from the top of the stack illustrated in fig. 7m, the preset function is called to directly calculate the memory thereof, assuming that the memory occupied by the object a itself is 22 bytes after calculation, and after the object a is popped from the top of the stack illustrated in fig. 7m, the state of the stack and the memory occupation analysis result of the object a are as illustrated in fig. 7 n.
In step S203, if the analysis of the memory usage of the preset number of objects is not completely completed within the current frame duration, the memory usage of the remaining objects in the preset number is analyzed within the subsequent frame duration of the current frame until the analysis of the memory usage of the preset number of objects is completely completed.
In the embodiment of the present application, although the frame-dividing logic of the network game may be used to analyze the memory usage of the preset number of objects within the current frame duration corresponding to the preset frame rate, as described above, since the duration of one frame is limited, the memory usage of the preset number of objects may not be analyzed within the duration of one frame. This typically occurs when the predetermined number of objects is too many to be pushed all the way onto the stack within the duration of a frame, and the remaining objects can only be pushed onto the stack again in the next frame. Only when all objects with a preset number are pushed into the stack, the memory occupation condition of the objects in the stack can be analyzed by backtracking the stack.
As an embodiment of the present application, if the analysis of the memory usage of the preset number of objects is not completely completed within the current frame duration, the memory usage of the remaining objects in the preset number is analyzed within the subsequent frame duration of the current frame until the analysis of the memory usage of the preset number of objects is completely completed, which may be performed by the following step S 4-1 And step S 4-2 And (3) completing:
step S 4-1 : if n objects pressed into the stack top are partial objects with a preset number within the current frame time of a preset frame rate, pressing the rest objects in the preset number into the stack top within the next frame time of the current frame;
step S 4-2 : if the preset number of objects are all pushed to the top of the stack within the next frame duration of the current frame, the process jumps to step S of the previous embodiment 1-2 To step S 1-3 Or step S 2-2 To step S 2-3 Otherwise, the flow jumps to step S 4-1 Until all objects with preset number are pressed into the stack top;
repeating the above step S 4-1 To step S 4-2 And analyzing the memory occupation condition of the preset number of objects until the analysis is completely finished.
As can be seen from the method for analyzing the memory usage status illustrated in fig. 2, when the server refreshes the game screen of the client according to the preset frame rate, the memory usage statuses of the preset number of objects are analyzed within the current frame duration corresponding to the preset frame rate, and the memory usage statuses of the preset number of objects are not completely analyzed within the current frame duration, and the memory usage statuses of the remaining objects in the preset number are continuously analyzed within the subsequent frame duration of the current frame.
In order to better implement the method for analyzing the memory occupation status of the embodiment of the present application, an embodiment of the present application further provides a device for analyzing the memory occupation status. Please refer to fig. 8, which is a schematic structural diagram of an apparatus for analyzing an occupied memory status according to an embodiment of the present disclosure. The apparatus for analyzing the memory usage may be a server or a functional module/unit thereof, and the apparatus illustrated in fig. 8 may include an object obtaining module 801, a first analyzing module 802, and a second analyzing module 803, where:
an object obtaining module 801, configured to obtain a preset number of objects;
a first analysis module 802, configured to analyze memory occupation statuses of a preset number of objects within a current frame duration corresponding to a preset frame rate when a game screen of a client is refreshed according to the preset frame rate;
the second analysis module 803 is configured to, if the analysis of the memory usage of the preset number of objects is not completely completed within the current frame time, analyze the memory usage of the remaining objects in the preset number within the subsequent frame time of the current frame until the analysis of the memory usage of the preset number of objects is completely completed.
Optionally, the first analysis module 802 in the example of fig. 8 may include a first push unit, a first pop unit, and a function call unit, where:
a first push unit for executing step S 1-1 I.e. current at a preset frame rateWithin a frame time length, pressing n objects to the stack top of a stack, wherein the n objects are part or all of preset number of objects, and n is a natural number;
a first pop unit for executing step S 1-2 That is, pop up the top object, where the top object is the object at the top of the stack;
a function call unit for executing step S 1-3 That is, a preset function is called, and the n objects popped from the top of the stack, the memory of any one sub-object of the n objects, and the sum of the memory of any one sub-object of the n objects and the sub-object thereof are calculated one by one.
Optionally, the first stacking unit may include an initialization unit, a first enqueuing unit, and a first top-of-stack operation unit, where:
the initialization unit is used for initializing a given queue to obtain an initialized queue;
the first enqueuing unit is used for storing each object and the sub-objects thereof in the n objects into the initialized queue;
and the first stack top operation unit is used for pushing the head object of the initialized queue to the stack top while storing each object and the child objects thereof in the n objects into the initialized queue until the initialized queue is empty again.
Optionally, the enqueue unit may include a root node storage unit, a second enqueue unit, and a third enqueue unit, where:
a root node storing unit for storing an object O of any tree structure of the n objects i To the object O i Storing the self as a root node into an initialized queue;
a second enqueuing unit for serving as the object O i Dequeuing itself from the initialized queue, object O i The child objects are stored in the initialized queue according to the following first principle: 1) object O i The sub-objects which are closer to the root node in all the sub-objects are stored into the initialized queue first; 2) the more the objects in the same level in the tree structure are stored in the initialized queue, the more the child objects are stored in the initialized queue;
a third enqueuing unit for processing the object O i Any one of the sub-objects O of ij Dequeuing from the initialized queue, child O ij The sub-objects are stored in the initialized queue according to the following second principle: 1) will sub-object O ij As a sub-object O ij Parent node of all child objects, child object O ij The child objects which are closer to the parent node in all the child objects are stored in the initialized queue first; 2) the more objects in the same level below the parent node are stored in the initialized queue, the more children are stored in the initialized queue.
Optionally, the first analysis module 802 illustrated in fig. 8 may include a second push unit, a read unit, and a memory analysis unit, where:
a second push unit for executing step S 2-1 That is, within the current frame duration of the preset frame rate, n objects are pressed to the top of the stack, where the n objects are part or all of the preset number of objects, and n is a natural number;
a reading unit for performing step S 2-2 Reading a stack top object, wherein the stack top object is an object located at the top of the stack;
a memory analysis unit for executing step S 2-3 That is, according to the state of the top object or whether the sub-objects of the top object have already been calculated by the memory, the memory occupation of the preset number of objects is analyzed by re-operating the top of the stack.
Optionally, the memory analysis unit may include a computing unit and a second stack top operation unit, where:
a computing unit for executing step S 3-1 That is, if the sub-object of the top stack object has already been calculated in the memory or the top stack object does not have a sub-object, the memory of the top stack object in which the sub-object does not exist or the top stack object in which the sub-object has already been calculated in the memory is calculated;
a first stack top operation unit for executing step S 3-2 That is, if the sub-object of the top-of-stack object has not been computed in memory, the sub-object of the top-of-stack object whose sub-object has not been computed in memory is replaced with the sub-object of the top-of-stack objectPressing into the stack top, and the flow goes to the step S 2-2 And until the memory occupation conditions of the n objects pressed into the stack top are completely analyzed.
Optionally, the second analysis module 803 illustrated in fig. 8 is specifically configured to execute step S 4-1 And step S 4-2 I.e. step S 4-1 : if n objects pressed into the stack top are partial objects with a preset number within the current frame time of a preset frame rate, pressing the rest objects in the preset number into the stack top within the next frame time of the current frame; step S 4-2 : if the preset number of objects are all pressed into the stack top within the next frame duration of the current frame, the flow goes to step S 1-2 To step S 1-3 Or step S 2-2 To step S 2-3 Otherwise, the flow goes to step S 4-1 Until all objects with preset number are pressed into the stack top; repeating the above step S 4-1 To step S 4-2 And analyzing the memory occupation condition of the preset number of objects until the analysis is completely finished.
All the above technical solutions can be combined arbitrarily to form the optional embodiments of the present application, and are not described herein again.
As can be known from the apparatus for analyzing memory usage illustrated in fig. 8, when the server refreshes the game screen of the client according to the preset frame rate, the server analyzes the memory usage of the preset number of objects in the current frame duration corresponding to the preset frame rate, and does not completely analyze the memory usage of the preset number of objects in the current frame duration, and continues to analyze the memory usage of the remaining objects in the preset number in the subsequent frame duration of the current frame.
Correspondingly, the embodiment of the present application further provides a Computer device, where the Computer device may be a terminal or a server, and the terminal may be a terminal device such as a smart phone, a tablet Computer, a notebook Computer, a touch screen, a game console, a Personal Computer (PC), a Personal Digital Assistant (PDA), and the like. As shown in fig. 9, fig. 9 is a schematic structural diagram of a computer device according to an embodiment of the present application. The computer device 900 includes a processor 901 having one or more processing cores, a memory 902 having one or more computer-readable storage media, and a computer program stored on the memory 902 and executable on the processor. The processor 901 is electrically connected to the memory 902. Those skilled in the art will appreciate that the computer device configurations illustrated in the figures are not meant to be limiting of computer devices and may include more or fewer components than those illustrated, or some components may be combined, or a different arrangement of components.
The processor 901 is a control center of the computer apparatus 900, connects various parts of the entire computer apparatus 900 by various interfaces and lines, performs various functions of the computer apparatus 900 and processes data by running or loading software programs and/or modules stored in the memory 902 and calling data stored in the memory 902, thereby monitoring the computer apparatus 900 as a whole.
In this embodiment of the application, the processor 901 in the computer device 900 loads instructions corresponding to processes of one or more application programs into the memory 902, and the processor 901 runs the application programs stored in the memory 902, so as to implement various functions as follows:
acquiring a preset number of objects; when the game picture of the client is refreshed according to the preset frame rate, analyzing the memory occupation condition of a preset number of objects in the current frame duration corresponding to the preset frame rate; if the analysis of the memory occupation conditions of the preset number of objects is not completely finished in the current frame time length, the memory occupation conditions of the remaining objects in the preset number are analyzed in the subsequent frame time length of the current frame until the analysis of the memory occupation conditions of the preset number of objects is completely finished.
The above operations can be implemented in the foregoing embodiments, and are not described in detail herein.
Optionally, as shown in fig. 9, the computer device 900 further includes: touch-sensitive display screen 903, radio frequency circuit 904, audio circuit 905, input unit 906 and power 907. The processor 901 is electrically connected to the touch display screen 903, the radio frequency circuit 904, the audio circuit 905, the input unit 906, and the power supply 907. Those skilled in the art will appreciate that the computer device configuration illustrated in FIG. 9 does not constitute a limitation of computer devices, and may include more or fewer components than those illustrated, or some components may be combined, or a different arrangement of components.
The touch screen 903 may be used for displaying a graphical user interface and receiving operation instructions generated by a user acting on the graphical user interface. The touch display screen 903 may include a display panel and a touch panel. The display panel may be used, among other things, to display information entered by or provided to a user and various graphical user interfaces of the computer device, which may be made up of graphics, text, icons, video, and any combination thereof. Alternatively, the Display panel may be configured in the form of a Liquid Crystal Display (LCD), an Organic Light-Emitting Diode (OLED), or the like. The touch panel may be used to collect touch operations of a user (for example, operations of the user on or near the touch panel by using a finger, a stylus pen, or any other suitable object or accessory) and generate corresponding operation instructions, and the operation instructions execute corresponding programs. Alternatively, the touch panel may include two parts, a touch detection device and a touch controller. The touch detection device detects the touch direction of a user, detects a signal brought by touch operation and transmits the signal to the touch controller; the touch controller receives touch information from the touch sensing device, converts the touch information into touch point coordinates, sends the touch point coordinates to the processor 901, and can receive and execute commands sent by the processor 901. The touch panel may cover the display panel, and when the touch panel detects a touch operation on or near the touch panel, the touch panel transmits the touch operation to the processor 901 to determine the type of the touch event, and then the processor 901 provides a corresponding visual output on the display panel according to the type of the touch event. In the embodiment of the present application, a touch panel and a display panel may be integrated into the touch display screen 903 to realize input and output functions. However, in some embodiments, the touch panel and the touch panel can be implemented as two separate components to perform the input and output functions. That is, the touch display 903 may also be used as a part of the input unit 906 to implement an input function.
In the embodiment of the present application, a processor 901 executes a game application to generate a graphical user interface on a touch display screen 903, where a virtual scene on the graphical user interface includes at least one skill control area, and the skill control area includes at least one skill control. The touch display screen 903 is used for presenting a graphical user interface and receiving an operation instruction generated by a user acting on the graphical user interface.
The radio frequency circuit 904 may be configured to transceive radio frequency signals to establish wireless communication with a network device or other computer device via wireless communication, and to transceive signals with the network device or other computer device.
The audio circuitry 905 may be used to provide an audio interface between a user and a computer device through speakers, microphones. The audio circuit 905 can transmit the electrical signal converted from the received audio data to a loudspeaker, and the electrical signal is converted into a sound signal by the loudspeaker and output; on the other hand, the microphone converts the collected sound signal into an electrical signal, which is received by the audio circuit 905 and converted into audio data, which is then processed by the audio data output processor 901 and then transmitted to, for example, another computer device via the radio frequency circuit 904, or output to the memory 902 for further processing. The audio circuitry 905 may also include an earbud jack to provide communication of peripheral headphones with the computer device.
The input unit 906 may be used to receive input numbers, character information, or user characteristic information (e.g., fingerprint, iris, facial information, etc.), and generate keyboard, mouse, joystick, optical, or trackball signal inputs related to user settings and function control.
A power supply 907 is used to power the various components of the computer device 900. Optionally, the power supply 907 may be logically connected to the processor 901 through a power management system, so as to implement functions of managing charging, discharging, power consumption management, and the like through the power management system. Power supply 907 may also include any component such as one or more dc or ac power sources, recharging systems, power failure detection circuitry, power converters or inverters, power status indicators, and the like.
Although not shown in fig. 9, the computer device 900 may further include a camera, a sensor, a wireless fidelity module, a bluetooth module, etc., which are not described in detail herein.
In the foregoing embodiments, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
As can be seen from the above, in the computer device provided in this embodiment, when the server refreshes the game screen of the client according to the preset frame rate, the server analyzes the memory occupation statuses of the preset number of objects in the current frame duration corresponding to the preset frame rate, and does not completely analyze the memory occupation statuses of the preset number of objects in the current frame duration, and continues to analyze the memory occupation statuses of the remaining objects in the preset number in the subsequent frame duration of the current frame.
It will be understood by those skilled in the art that all or part of the steps of the methods of the above embodiments may be performed by instructions or by associated hardware controlled by the instructions, which may be stored in a computer readable storage medium and loaded and executed by a processor.
To this end, embodiments of the present application provide a computer-readable storage medium, in which a plurality of computer programs are stored, and the computer programs can be loaded by a processor to perform the steps in any method for analyzing memory usage provided by the embodiments of the present application. For example, the computer program may perform the steps of:
acquiring a preset number of objects; when the game picture of the client is refreshed according to the preset frame rate, analyzing the memory occupation condition of a preset number of objects in the current frame duration corresponding to the preset frame rate; if the analysis of the memory occupation conditions of the preset number of objects is not completely finished in the current frame time length, the memory occupation conditions of the remaining objects in the preset number are analyzed in the subsequent frame time length of the current frame until the analysis of the memory occupation conditions of the preset number of objects is completely finished.
The above operations can be implemented in the foregoing embodiments, and are not described in detail herein.
Wherein the storage medium may include: read Only Memory (ROM), Random Access Memory (RAM), magnetic or optical disks, and the like.
Since the computer program stored in the storage medium can execute the steps in any method for analyzing the memory usage status provided in the embodiment of the present application, the beneficial effects that can be achieved by any method for analyzing the memory usage status provided in the embodiment of the present application can be achieved, which are detailed in the foregoing embodiments and will not be described herein again.
The method, the apparatus, the storage medium, and the computer device for analyzing the memory usage provided by the embodiments of the present application are introduced in detail, and a specific example is applied in the description to explain the principle and the implementation of the present application, and the description of the embodiments is only used to help understand the method and the core idea of the present application; meanwhile, for those skilled in the art, according to the idea of the present application, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present application.

Claims (10)

1. A method for analyzing memory footprint, comprising:
acquiring a preset number of objects;
when the game picture of the client is refreshed according to a preset frame rate, analyzing the memory occupation condition of the preset number of objects within the current frame duration corresponding to the preset frame rate;
if the analysis of the memory occupation conditions of the preset number of objects is not completely finished in the current frame time length, analyzing the memory occupation conditions of the remaining objects in the preset number in the subsequent frame time length of the current frame until the analysis of the memory occupation conditions of the preset number of objects is completely finished.
2. The method according to claim 1, wherein the analyzing the memory usage of the predetermined number of objects within the current frame duration corresponding to the predetermined frame rate includes:
step S 1-1 : within the current frame duration of the preset frame rate, pressing n objects to the stack top of the stack, wherein the n objects are part of or all of the preset number of objects, and n is a natural number;
step S 1-2 : popping a stack top object, wherein the stack top object is an object positioned at the top of the stack;
step S 1-3 : and calling a preset function, and calculating n objects popped out from the stack top, the memory of any one of the sub-objects of the n objects, and the sum of the memory of any one of the sub-objects of the n objects and the memory of the sub-objects of the n objects one by one.
3. The method according to claim 2, wherein the pushing n objects to the top of the stack within the current frame duration corresponding to the preset frame rate comprises:
initializing a given queue to obtain an initialized queue;
storing each object and its sub-objects in the n objects into the initialized queue;
and pushing a head object of the initialized queue to the top of the stack while storing each object and the sub-objects thereof in the n objects into the initialized queue until the initialized queue is empty again.
4. The method of claim 3, wherein storing each of the n objects and its children in the initialized queue comprises:
for the object O of any tree structure in the n objects i The object O is i Storing the self as a root node into the initialized queue;
when the object O is i Dequeuing itself from the initialized queue, the object O i The sub-objects are stored in the initialized queue according to the following first principle: 1) the object O i The sub-objects which are closer to the root node in all the sub-objects are stored in the initialized queue first; 2) the object of the same level in the tree structure is stored into the initialized queue first, and the sub-objects are also stored into the initialized queue first;
when the object O is i Any one of the sub-objects O of ij Dequeuing the child object O from the initialized queue ij The sub-objects are stored in the initialized queue according to the following second principle: 1) the sub-object O ij As the sub-object O ij Parent node of all children, said children O ij The child objects which are closer to the parent node in all the child objects are stored in the initialized queue first; 2) the object of the same layer below the father node is stored into the initialized queue first, and the child object is stored into the initialized queue first.
5. The method according to claim 1, wherein the analyzing the memory usage of the predetermined number of objects within the current frame duration corresponding to the predetermined frame rate includes:
step S 2-1 : within the current frame duration of the preset frame rate, pressing n objects to the stack top of the stack, wherein the n objects are part of or all of the preset number of objects, and n is a natural number;
step S 2-2 : reading a stack top object, wherein the stack top object is locatedAn object at the top of the stack;
step S 2-3 : and analyzing the memory occupation condition of the preset number of objects by performing re-operation on the stack top according to the state of the stack top object or whether the sub-objects of the stack top object are already calculated by the memory.
6. The method according to claim 5, wherein the analyzing the memory usage of the preset number of objects by performing a re-operation on the stack top according to the status of the stack top object or whether the sub-objects of the stack top object have already been calculated by the memory comprises:
step S 3-1 : if the sub-object of the top-of-stack object has already been calculated in the memory or the top-of-stack object does not have a sub-object, calculating the memory of the top-of-stack object without the sub-object or the top-of-stack object with the sub-object already calculated in the memory;
step S 3-2 : if the sub-object of the stack top object is not calculated in the memory, pressing the sub-object of the stack top object of which the sub-object is not calculated in the memory into the stack top, and skipping to the step S 2-2 And until the memory occupation conditions of the n objects pressed into the stack top are completely analyzed.
7. The method according to claim 2 or 5, wherein if the analysis of the memory usage of the preset number of objects is not completely completed within the current frame duration, the analyzing of the memory usage of the remaining objects in the preset number within the subsequent frame duration of the current frame until the analysis of the memory usage of the preset number of objects is completely completed includes:
step S 4-1 : if the n objects pressed into the stack top in the current frame duration of the preset frame rate are part of the objects in the preset number, pressing the rest objects in the preset number into the stack top in the next frame duration of the current frame;
step S 4-2 : if the preset number of objects are all pressed into the stack top within the next frame duration of the current frame, the flow goes to step S 1-2 To step S 1-3 Or step S 2-2 To step S 2-3 Otherwise, the flow goes to step S 4-1 Until all the objects with the preset number are pressed into the stack top;
repeating the above step S 4-1 To step S 4-2 And analyzing the memory occupation condition of the preset number of objects until the analysis is completely finished.
8. An apparatus for analyzing memory usage, comprising:
the object acquisition module is used for acquiring a preset number of objects;
the first analysis module is used for analyzing the memory occupation condition of the preset number of objects within the current frame duration corresponding to the preset frame rate when the game screen of the client is refreshed according to the preset frame rate;
and a second analysis module, configured to, if the analysis of the memory usage of the preset number of objects is not completely completed within the current frame time, analyze the memory usage of the remaining objects in the preset number within a subsequent frame time of the current frame until the analysis of the memory usage of the preset number of objects is completely completed.
9. A computer-readable storage medium, storing a computer program adapted to be loaded by a processor to perform the steps of the method for analyzing memory footprint as claimed in any one of claims 1 to 7.
10. A computer device, characterized in that the computer device comprises a memory and a processor, the memory stores a computer program, the processor executes the steps of the method for analyzing the memory usage condition according to any one of claims 1 to 7 by calling the computer program stored in the memory.
CN202110661596.XA 2021-06-15 2021-06-15 Method and device for analyzing memory occupation condition, storage medium and computer equipment Active CN113360343B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110661596.XA CN113360343B (en) 2021-06-15 2021-06-15 Method and device for analyzing memory occupation condition, storage medium and computer equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110661596.XA CN113360343B (en) 2021-06-15 2021-06-15 Method and device for analyzing memory occupation condition, storage medium and computer equipment

Publications (2)

Publication Number Publication Date
CN113360343A CN113360343A (en) 2021-09-07
CN113360343B true CN113360343B (en) 2022-08-16

Family

ID=77534194

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110661596.XA Active CN113360343B (en) 2021-06-15 2021-06-15 Method and device for analyzing memory occupation condition, storage medium and computer equipment

Country Status (1)

Country Link
CN (1) CN113360343B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108280009A (en) * 2017-12-25 2018-07-13 福建天晴数码有限公司 A kind of method and terminal of monitoring gridding resource
CN110162451A (en) * 2019-04-22 2019-08-23 腾讯科技(深圳)有限公司 A kind of method for analyzing performance, device, server and storage medium
CN110196799A (en) * 2018-02-24 2019-09-03 腾讯科技(深圳)有限公司 A kind of client performance test method, device and terminal
CN112231186A (en) * 2019-07-15 2021-01-15 深圳市腾讯网域计算机网络有限公司 Performance data processing method and device, electronic equipment and medium

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8843526B2 (en) * 2009-12-18 2014-09-23 Sap Ag Application specific memory consumption and analysis

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108280009A (en) * 2017-12-25 2018-07-13 福建天晴数码有限公司 A kind of method and terminal of monitoring gridding resource
CN110196799A (en) * 2018-02-24 2019-09-03 腾讯科技(深圳)有限公司 A kind of client performance test method, device and terminal
CN110162451A (en) * 2019-04-22 2019-08-23 腾讯科技(深圳)有限公司 A kind of method for analyzing performance, device, server and storage medium
CN112231186A (en) * 2019-07-15 2021-01-15 深圳市腾讯网域计算机网络有限公司 Performance data processing method and device, electronic equipment and medium

Also Published As

Publication number Publication date
CN113360343A (en) 2021-09-07

Similar Documents

Publication Publication Date Title
CN110585726B (en) User recall method, device, server and computer readable storage medium
CN113101652A (en) Information display method and device, computer equipment and storage medium
US20220072420A1 (en) Frame display method and apparatus in game application, terminal, and storage medium
CN112274923B (en) Game skill information prompting method and device, storage medium and computer equipment
CN113350782A (en) Method, device, storage medium and computer equipment for processing online game abnormity
CN113952720A (en) Game scene rendering method and device, electronic equipment and storage medium
CN110879850B (en) Method, device and equipment for acquiring jitter parameters and storage medium
CN113786620A (en) Game information recommendation method and device, computer equipment and storage medium
CN115040873A (en) Game grouping processing method and device, computer equipment and storage medium
CN112169310A (en) Game resource loading method and device, computer equipment and storage medium
CN113360343B (en) Method and device for analyzing memory occupation condition, storage medium and computer equipment
CN115068941A (en) Game image quality recommendation method and device, computer equipment and storage medium
CN115888101A (en) Virtual role state switching method and device, storage medium and electronic equipment
CN115225971A (en) Video progress adjusting method and device, computer equipment and storage medium
CN115193043A (en) Game information sending method and device, computer equipment and storage medium
CN114225412A (en) Information processing method, information processing device, computer equipment and storage medium
CN113617027A (en) Cloud game processing method, device, equipment and medium
CN113350801A (en) Model processing method and device, storage medium and computer equipment
CN111589118A (en) User interface display method, device, equipment and storage medium
CN113426121B (en) Game control method, game control device, storage medium and computer equipment
CN114632328A (en) Method, device, terminal and storage medium for displaying special effects in game
CN113332731A (en) Method and device for issuing rewards of game, storage medium and computer equipment
CN115040867A (en) Game card control method and device, computer equipment and storage medium
JP7008970B2 (en) Game equipment, game execution methods, and programs
CN115430150A (en) Game skill release method and device, computer equipment and storage medium

Legal Events

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