CN106951306A - A kind of STW detection methods, device and equipment - Google Patents

A kind of STW detection methods, device and equipment Download PDF

Info

Publication number
CN106951306A
CN106951306A CN201710128832.5A CN201710128832A CN106951306A CN 106951306 A CN106951306 A CN 106951306A CN 201710128832 A CN201710128832 A CN 201710128832A CN 106951306 A CN106951306 A CN 106951306A
Authority
CN
China
Prior art keywords
address
difference
current
stw
pointer address
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.)
Granted
Application number
CN201710128832.5A
Other languages
Chinese (zh)
Other versions
CN106951306B (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.)
Neusoft Corp
Original Assignee
Neusoft Corp
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 Neusoft Corp filed Critical Neusoft Corp
Priority to CN201710128832.5A priority Critical patent/CN106951306B/en
Publication of CN106951306A publication Critical patent/CN106951306A/en
Application granted granted Critical
Publication of CN106951306B publication Critical patent/CN106951306B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5016Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/4557Distribution of virtual machine instances; Migration and load balancing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45583Memory management, e.g. access or allocation

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Image Analysis (AREA)
  • Tests Of Electronic Circuits (AREA)

Abstract

This application discloses a kind of STW detection methods, device and equipment, method includes:The initial address difference for obtaining the first object between pointer address when the second object is each created, wherein, first object and second object are respectively the strongly reference object being pre-created, and at least one the 3rd object has also been pre-created between first object and the respective pointer address of the second object, the 3rd object is weak reference object;Obtain first object and the respective current pointer address of second object;Based on first object and the respective current pointer address of second object, the current address difference between first object and second object is obtained;The initial address difference is compared with the current address difference, comparison result is obtained;When the comparison result meets default address distance change condition, the testing result that STW is likely to occur in the JVM is generated.

Description

A kind of STW detection methods, device and equipment
Technical field
The application is related to virtual machine technique field, more particularly to a kind of STW detection methods, device and equipment.
Background technology
Java is compared to an advantage of other Languages:It need not show and be managed when carrying out Object Management group to java Object content, but Memory Allocation and the recovery of object are automatically carried out by Java Virtual Machine (JVM).Internal memory in Java Reclaiming principle is:If object is not cited, the internal memory of the object can be recovered.
In Memory recycle, JVM carries out Memory recycle under different scenes using different ways of recycling.It is for example conventional to return Memory headroom to be recycled is only discharged in debit's formula, and when memory fragmentation is more, by the way of compacting is reclaimed, i.e., first Release memory headroom to be recycled, in addition it is also necessary to rearranged remaining data or object in internal memory, to eliminate internal memory Fragment.
And when JVW carries out compacting recovery, it may occur that stop the world are STW phenomenon.If JVW is entering There is STW during reclaiming in row compacting, then JVM can hang up all user threads, now the user program quilt in JVM Stop completely, can just recover response after STW terminates.Therefore, when STW occurs, JVW user program cannot respond to outside Boundary is asked, and causes the cluster belonging to JVM or application not to run normally, accordingly, it would be desirable to the appearance to STW is detected in time, To notify to the external world correspondingly to be operated, it is to avoid occur the situation that the application comprising JVW or cluster can not normally be run.
The content of the invention
In view of this, the purpose of the application is to provide a kind of STW detection methods, device and equipment, existing to solve STW technical problem can not be detected in technology in time.
This application provides a kind of STW detection methods, including:
The initial address difference for obtaining the first object between pointer address when the second object is each created, wherein, First object and second object are respectively the strongly reference object being pre-created, and first object and described second At least one the 3rd object is also pre-created between the respective pointer address of object, the 3rd object is weak reference object;
Obtain first object and the respective current pointer address of second object;
Based on first object and the respective current pointer address of second object, first object and institute are obtained State the current address difference between the second object;
The initial address difference is compared with the current address difference, comparison result is obtained;
When the comparison result meets default address distance change condition, generate in the JVM and be likely to occur STW's Testing result.
The above method, it is preferred that the address distance change condition is:Between first object and second object Address distance change;
The comparison result meets default address distance change condition, including:
The comparison result shows that first object and the initial address difference of second object and current address are poor Value compares inconsistent.
The above method, it is preferred that acquisition first object and the respective current pointer address of second object, Including:
Using JNI methods, first object and the respective current pointer address of second object are obtained.
The above method, it is preferred that described to be based on first object and the respective current pointer address of second object, The current address difference between first object and second object is obtained, including:
The value of the current pointer address of second object is subtracted to the amount of the current pointer address of first object Value, obtains value subtraction result;
The absolute value of the value subtraction result is taken as the current position between first object and second object Location difference.
This application provides a kind of STW detection means, including:
Between initial difference acquiring unit, pointer address when being each created for the first object of acquisition and the second object Initial address difference, wherein, first object and second object are respectively the strongly reference object being pre-created, and institute State and at least one the 3rd object has also been pre-created between the first object and the respective pointer address of the second object, described Three objects are weak reference object;
Address acquisition unit, for obtaining first object and the respective current pointer address of second object;
Current difference acquiring unit, for based on first object and the respective current pointer of the second object Location, obtains the current address difference between first object and second object;
Difference comparing unit, for the initial address difference to be compared with the current address difference, is compared To result;
As a result generation unit, described for when the comparison result meets default address distance change condition, generating STW testing result is likely to occur in JVM.
Said apparatus, it is preferred that the address distance change condition is:Between first object and second object Address distance change;
The result generation unit specifically for:Comparison result show first object and second object just When beginning difference in address compares inconsistent with current address difference, the testing result that STW is likely to occur in the JVM is generated.
Said apparatus, it is preferred that the address acquisition unit specifically for:Using JNI methods, first object is obtained And the respective current pointer address of the second object.
Said apparatus, it is preferred that the current difference acquiring unit includes:
Magnitude calculation subelement, for the value of the current pointer address of second object to be subtracted into first object Current pointer address value, obtain value subtraction result;
Take absolute value subelement, for taking the absolute value of the value subtraction result as first object and described the Current address difference between two objects.
Present invention also provides a kind of STW detection devices, including:
Memory, for storing application program and the produced data of application program operation;
Processor, for performing the application program, to realize following functions:The first object is obtained with the second object each Initial address difference between pointer address when being created, wherein, first object is respectively pre- with second object Also it has been pre-created between the strongly reference object first created, and first object and the respective pointer address of the second object At least one the 3rd object, the 3rd object is weak reference object;Obtain first object and second object each Current pointer address;Based on first object and the respective current pointer address of second object, described first is obtained Current address difference between object and second object;The initial address difference and the current address difference are carried out Compare, obtain comparison result;When the comparison result meets default address distance change condition, generating can in the JVM STW testing result can occur.
A kind of STW detection methods, device and the equipment provided from such scheme, the application, by pre-setting two Individual strongly reference object, and monitor the address difference of two strongly reference objects after setting weak reference object between strongly reference object Whether value meets address distance change condition (for example, whether the address distance between two strongly reference objects of monitoring changes Deng), and then judge to reclaim either with or without the compacting for carrying out internal memory in JVM, the thus address difference between two strongly reference objects The testing result that STW is likely to occur in JVM is generated when value changes, the real-time inspection to whether being likely to occur STW in JVM is realized Survey.
Brief description of the drawings
In order to illustrate more clearly about the embodiment of the present invention or technical scheme of the prior art, below will be to embodiment or existing The accompanying drawing to be used needed for having technology description is briefly described, it should be apparent that, drawings in the following description are only this The embodiment of invention, for those of ordinary skill in the art, on the premise of not paying creative work, can also basis The accompanying drawing of offer obtains other accompanying drawings.
Fig. 1 realizes flow chart for a kind of STW detection methods of the offer of the embodiment of the present application one;
Fig. 2 is the application exemplary plot of the embodiment of the present application;
Fig. 3 is a kind of structural representation for STW detection means that the embodiment of the present application two is provided;
Fig. 4 is the part-structure schematic diagram of the embodiment of the present application two;
Fig. 5 is a kind of structural representation for STW detection devices that the embodiment of the present application three is provided.
Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the present invention, the technical scheme in the embodiment of the present invention is carried out clear, complete Site preparation is described, it is clear that described embodiment is only a part of embodiment of the invention, rather than whole embodiments.It is based on Embodiment in the present invention, it is every other that those of ordinary skill in the art are obtained under the premise of creative work is not made Embodiment, belongs to the scope of protection of the invention.
With reference to Fig. 1, it is that a kind of STW detection methods that the embodiment of the present application one is provided realize flow chart, applies in JVM In, to be detected in time to whether occurring STW in JVM, specifically, in the present embodiment, this method can include following Step:
Step 101:Obtain the first object and the respective current pointer address of the second object.
Wherein, the first object and the second object are respectively the strongly reference object that the present embodiment is pre-created, this strongly reference Object will not be recovered when the compacting of internal memory is reclaimed, and the first object is created in the first pointer address, and the second object is created In the second pointer address, as shown in Figure 2.
And it has been pre-created at least one the 3rd object between the first object and the respective pointer address of the second object, 3rd object is weak reference object, and this weak reference object can be recovered when the compacting of internal memory is reclaimed.As shown in Figure 2, Three objects are created between the first object and the second object, are:The 3rd pointer address that 3rd object is created is between Between one pointer address and the second pointer address.
The 3rd object in the present embodiment can be 1, or multiple.And in order to increase the accuracy of detection, the The quantity of three objects can be set to multiple in the allowed band of memory headroom, and such as 4 even more.
It should be noted that because the compacting that internal memory may be carried out in JVM is reclaimed, therefore, the first object and second pair As respective pointer address there may be change, the first object and the respective current pointer address of the second object are different from two strong Pointer address when reference object is created, therefore, the current pointer address of the first object may phases with its first pointer address Together may also be different, the current pointer address of the second object is identical from its second pointer address possibility may also be different.
Wherein, the first object and the respective current pointer of the second object can be obtained in the present embodiment using JNI methods Address.
Step 102:Based on the first object and the respective current pointer address of the second object, the first object and second pair are obtained Current address difference as between.
Wherein, current address difference be current pointer address and the second object of the first object current pointer address it Between address offset amount size.
Specifically, current address difference can be obtained in the present embodiment in the following manner:
The value of the current pointer address of second object is subtracted to the value of the current pointer address of the first object first, obtained To value subtraction result;
Then the absolute value of taken amount value subtraction result is used as the current address between the first object and second object then, Difference.
Step 103:The initial address for obtaining the first object between pointer address when the second object is each created is poor Value.
As shown in Figure 2, initial address difference is:Address offset between first pointer address and the second pointer address The size of amount.The initial address difference is different from above-mentioned current address difference, and initial address difference refers to first under original state Offset size between the pointer address of the pointer address of object and the second object, and between the first object and the second object Current address difference refers to the pointer address and the second object that the first object under current state after the regular hour is run in JVM Pointer address between offset size.
Accordingly, the initial address difference between the first object and the second object is identical with current address difference possibility, May be different.If the compacting that internal memory did not occur between the first object and the second object for JVM is reclaimed, then initial address Difference is identical with current address difference;If the compacting that internal memory occurred between the first object and the second object for JVM is reclaimed, that Initial address difference is different from current address difference.
It should be noted that the execution sequence of step 103 and the execution sequence of step 102 are unrestricted, for example, step 103 can perform before step 101 and step 102, or, step 103 can be performed after step 101 and step 102, Or, step 103 synchronous with step 101 or sign 102 can be performed.
And it is preferred that, step 103 can perform after the first object and the second object are created, and then need to carry out When STW is detected, then step 101 and step 102 and subsequent step are performed, realize the present embodiment.
Step 104:Initial address difference is compared with current address difference, comparison result is obtained, in comparison result When meeting default address distance change condition, step 105 is performed.
Wherein, initial address difference is the sizes values of address offset amount with current address difference, therefore, in the present embodiment Can directly by two differences, whether size is identical is compared, obtain comparison result.
And default address distance change condition can be:Whether the address distance between the first object and the second object is sent out Changing, that is to say, that whether the comparison of initial address difference and current address difference between the first object and the second object Unanimously.As whether the offset between the first pointer address and the second pointer address in Fig. 2 changes.
It should be noted that in comparison result, if initial address difference is compared unanimously with current address difference, that is, Two differences are identical, then may indicate that the distance of the address between the first object and the second object does not change, then show the There is no the compacting for occurring internal memory to reclaim between one object and the second object, then with regard to not carrying out or occurring STW;If initial Difference in address compared with current address difference it is inconsistent, that is, two difference differences, then may indicate that the first object and second Address distance between object changes, now, shows to carry out the pressure of internal memory between the first object and the second object certainly It is real to reclaim, then may occur STW.
Step 105:STW testing result is likely to occur in generation JVM.
Wherein, the testing result for occurring STW in JVM is represented:STW may be carried out in JVM.
It should be noted that when detecting to be likely to occur STW, completing detection, then can delete two strongly reference objects That is the first object and the second object, save memory headroom.
A kind of STW detection methods provided from such scheme, the embodiment of the present application one are strong by pre-setting two Reference object, and between strongly reference object after setting weak reference object, the difference in address of two strongly reference objects of monitoring is The no address distance change condition that meets is (for example, whether the address distance between the first object of monitoring and the second object changes Deng), and then judge to reclaim either with or without the compacting for carrying out internal memory in JVM, the thus address difference between two strongly reference objects STW testing result may be carried out by being generated when value changes in JVM, be realized to that whether may carry out STW reality in JVM When detect.
It should be noted that in the present embodiment, after a STW detection is completed, can return and re-execute embodiment, Carry out STW detections next time.For example, after step 105 monitors STW, returning and performing step 101, carry out STW's again Detection.
It should be noted that the detection for carrying out STW again refers to monitor STW appearance in JVM again, then the present embodiment In, the operation for being pre-created two strongly reference objects and at least one weak reference object is also required to re-execute, and Object Creation is complete After, when needing to carry out STW detections, then the difference in address between two strongly reference objects is obtained, and whether judge difference Change, and then detect whether STW is likely to occur.
It is a kind of structural representation for STW detection means that the embodiment of the present application two is provided with reference to Fig. 3, wherein, apply In JVM, to be detected in time to whether occurring STW in JVM, specifically, in the present embodiment, the device can include with Lower structure:
Address acquisition unit 301, for obtaining the first object and the respective current pointer address of the second object.
Wherein, the first object and the second object are respectively the strongly reference object that the present embodiment is pre-created, this strongly reference Object will not be recovered when the compacting of internal memory is reclaimed, and the first object is created in the first pointer address, and the second object is created In the second pointer address, as shown in Figure 2.
And it has been pre-created at least one the 3rd object between the first object and the respective pointer address of the second object, 3rd object is weak reference object, and this weak reference object can be recovered when the compacting of internal memory is reclaimed.As shown in Figure 2, Three objects are created between the first object and the second object, are:The 3rd pointer address that 3rd object is created is between Between one pointer address and the second pointer address.
The 3rd object in the present embodiment can be 1, or multiple.And in order to increase the accuracy of detection, the The quantity of three objects can be set to multiple in the allowed band of memory headroom, and such as 4 even more.
It should be noted that because the compacting that internal memory may be carried out in JVM is reclaimed, therefore, the first object and second pair As respective pointer address there may be change, the first object and the respective current pointer address of the second object are different from two strong Pointer address when reference object is created, therefore, the current pointer address of the first object may phases with its first pointer address Together may also be different, the current pointer address of the second object is identical from its second pointer address possibility may also be different.
Wherein, the first object and the respective current pointer of the second object can be obtained in the present embodiment using JNI methods Address.
Current difference acquiring unit 302, for based on the first object and the respective current pointer address of the second object, obtaining Current address difference between first object and the second object.
Wherein, current address difference be current pointer address and the second object of the first object current pointer address it Between address offset amount size.
Specifically, current address difference can be obtained by following structure in the present embodiment, it is as shown in Figure 4, current poor Value acquiring unit 302 can include following structure:
Magnitude calculation subelement 401, for the value of the current pointer address of the second object to be subtracted into working as the first object The value of prior pointer address, obtains value subtraction result.
Take absolute value subelement 402, for taken amount value subtraction result absolute value as the first object and the second object it Between current address difference.
Initial difference acquiring unit 303, pointer address when being each created for the first object of acquisition and the second object Between initial address difference.
As shown in Figure 2, initial address difference is:Address offset between first pointer address and the second pointer address The size of amount.The initial address difference is different from above-mentioned current address difference, with referring under original state the pointer of the first object Offset size between the pointer address of location and the second object, and the current address difference between the first object and the second object Refer to the pointer address of the first object and the second object under current state after JVM runs the regular hour pointer address it Between offset size.
It should be noted that initial difference acquiring unit 303 and address acquisition unit 301 and current difference acquiring unit 302 operation order can be with unrestricted, such as:Initial difference acquiring unit 303 can be in address acquisition unit 301 and current Run before difference acquiring unit 302, or, initial difference acquiring unit 303 can be in address acquisition unit 301 and current poor It is worth operation after acquiring unit 302, or, initial difference acquiring unit 303 can be with address acquisition unit 301 or current difference Acquiring unit 302 is run simultaneously.
And it is preferred that, initial difference acquiring unit 303 can be triggered fortune after the first object and the second object are created OK, then when needing to carry out STW detections, address acquisition unit of reruning 301 and current difference acquiring unit 302 and other lists Member, realizes the present embodiment.
Difference comparing unit 304, for initial address difference to be compared with current address difference, obtains comparing knot Really.
Wherein, initial address difference is the sizes values of address offset amount with current address difference, therefore, in the present embodiment Can directly by two differences, whether size is identical is compared, obtain comparison result.
As a result generation unit 305, the comparison result for being obtained in difference comparing unit 304 meets default address distance During change condition, the testing result that STW is likely to occur in the JVM is generated.
Wherein, default address distance change condition can be:Address distance between first object and the second object is It is no to change, that is to say, that the comparison of initial address difference and current address difference between the first object and the second object It is whether consistent.As whether the offset between the first pointer address and the second pointer address in Fig. 2 changes.
It should be noted that in comparison result, if initial address difference is compared unanimously with current address difference, that is, Two differences are identical, then may indicate that the distance of the address between the first object and the second object does not change, then show the There is no the compacting for occurring internal memory to reclaim between one object and the second object, then with regard to not carrying out or occurring STW;If initial Difference in address compared with current address difference it is inconsistent, that is, two difference differences, then may indicate that the first object and second Address distance between object changes, now, shows to carry out the pressure of internal memory between the first object and the second object certainly It is real to reclaim, then may occur STW.
Wherein, the testing result that STW is likely to occur in JVM is represented:STW may be carried out in JVM.
It should be noted that when detecting to be likely to occur STW, completing detection, then can delete two strongly reference objects That is the first object and the second object, save memory headroom.
A kind of STW detection means provided from such scheme, the embodiment of the present application two is strong by pre-setting two Reference object, and between strongly reference object after setting weak reference object, the difference in address of two strongly reference objects of monitoring is The no address distance change condition that meets is (for example, whether the address distance between the first object of monitoring and the second object changes Deng), and then judge to reclaim either with or without the compacting for carrying out internal memory in JVM, the thus address difference between two strongly reference objects STW testing result may be carried out by being generated when value changes in JVM, be realized to that whether may carry out STW reality in JVM When detect.
With reference to the structural representation that Fig. 5 is a kind of STW detection devices that the embodiment of the present application three is provided, apply in JVM, To be detected in time to whether occurring STW in JVM.
Wherein, the equipment can include following structure:
Memory 501, for storing application program and the produced data of application program operation;
Processor 502, for performing the application program, to realize following functions:Obtain the first object and the second object The initial address difference between pointer address when being each created, wherein, the first object and the second object are respectively advance wound Also be pre-created between the strongly reference object built, and the first object and the respective pointer address of the second object at least one the 3rd Object, the 3rd object is weak reference object, and the first object and the respective current pointer address of the second object are obtained afterwards;Based on One object and the respective current pointer address of the second object, obtain the current address difference between the first object and the second object; Initial address difference is compared with current address difference, comparison result is obtained;Comparison result meet default address away from During from change condition, STW testing result is likely to occur in generation JVM.
The specific implementation of processor may be referred to hereinbefore corresponding embodiment content in the present embodiment, no longer detailed herein State.
A kind of STW detection devices provided from such scheme, the embodiment of the present application three are strong by pre-setting two Reference object, and between strongly reference object after setting weak reference object, the difference in address of two strongly reference objects of monitoring is The no address distance change condition that meets is (for example, whether the address distance between the first object of monitoring and the second object changes Deng), and then judge to reclaim either with or without the compacting for carrying out internal memory in JVM, the thus address difference between two strongly reference objects STW testing result may be carried out by being generated when value changes in JVM, be realized to that whether may carry out STW reality in JVM When detect.
STW detection schemes in the present embodiment may apply in many scenes, by taking kafka clusters as an example:
In kafka clusters, the one of factor for causing leader state changes is exactly that STW occurs for leader, in hair During raw STW, it is impossible to send heartbeat in time, and do not received in cluster after leader heartbeat, cluster may be caused to re-elect Go out new leader, so leader nodes need timing to be asked to the pocket transmission of zookeeper collection, confirm its leader state, Leader resources are consumed, increase zookeeper workloads so that scheme is relatively complicated.
And use after the STW detection schemes in the present embodiment, leader can regularly detect the STW states of oneself, if Occurred STW, then asked to the pocket transmission of zookeeper collection, so as to reduce zookeeper workloads.
It should be noted that the device of the embodiment of the present application may be provided in the terminal with JVM, there is place in the terminal Manage device, memory and disk, computing device Object Creation and difference in address are calculated with comparing etc. work.
Kernel is included in processor, is gone in memory to transfer corresponding program unit by kernel.Kernel can set one Or more, termination function is realized by adjusting kernel parameter, as with creating strongly reference object and weak reference object, acquisition object Location, calculating difference in address and difference are than equity.
Memory potentially includes the volatile memory in computer-readable medium, random access memory (RAM) and/ Or the form, such as read-only storage (ROM) or flash memory (flash RAM) such as Nonvolatile memory, memory is deposited including at least one Store up chip.
Present invention also provides a kind of computer program product, it is arranged in the terminal with JVM, when in terminal such as computer Or when being performed on server, it is adapted for carrying out the program code of initialization there are as below methods step:
The first object and the respective current pointer address of the second object are obtained, wherein, the first object and the second object are distinguished For the strongly reference object being pre-created in JVM, created in advance on the pointer address in JVM also between the first object and the second object At least one the 3rd object is had, the 3rd object is weak reference object;Based on the respective current finger of the first object and the second object Pin address, obtains the current address difference between the first object and the second object;Obtain the first object and the second object each quilt Initial address difference between pointer address during establishment;Initial address difference is compared with current address difference, obtained Comparison result;When comparison result meets default address distance change condition, there is STW testing result in generation JVM.
Thus, the present embodiment is set by pre-setting two strongly reference objects in JVM, and between strongly reference object After weak reference object, whether the difference in address of two strongly reference objects of monitoring meets address distance change condition, such as whether not having Change, and then judge to reclaim either with or without the compacting for carrying out internal memory in JVM, thus between two strongly reference objects Difference in address STW testing result was carried out when changing in generation JVM, realize the reality to whether carrying out STW in JVM When detect.
It should be noted that herein, such as first and second or the like relational terms are used merely to a reality Body or operation make a distinction with another entity or operation, and not necessarily require or imply these entities or deposited between operating In any this actual relation or order.Moreover, term " comprising ", "comprising" or its any other variant are intended to Nonexcludability is included, so that process, method, article or equipment including a series of key elements not only will including those Element, but also other key elements including being not expressly set out, or also include being this process, method, article or equipment Intrinsic key element.In the absence of more restrictions, the key element limited by sentence "including a ...", it is not excluded that Also there is other identical element in process, method, article or equipment including the key element.
It should be understood by those skilled in the art that, embodiments herein can be provided as method, system or computer program Product.Therefore, the application can be using the reality in terms of complete hardware embodiment, complete software embodiment or combination software and hardware Apply the form of example.Moreover, the application can be used in one or more computers for wherein including computer usable program code The computer program production that usable storage medium is implemented on (including but is not limited to magnetic disk storage, CD-ROM, optical memory etc.) The form of product.
The application is the flow with reference to method, equipment (system) and computer program product according to the embodiment of the present application Figure and/or block diagram are described.It should be understood that every one stream in flow chart and/or block diagram can be realized by computer program instructions Journey and/or the flow in square frame and flow chart and/or block diagram and/or the combination of square frame.These computer programs can be provided The processor of all-purpose computer, special-purpose computer, Embedded Processor or other programmable data processing devices is instructed to produce A raw machine so that produced by the instruction of computer or the computing device of other programmable data processing devices for real The device for the function of being specified in present one flow of flow chart or one square frame of multiple flows and/or block diagram or multiple square frames.
These computer program instructions, which may be alternatively stored in, can guide computer or other programmable data processing devices with spy Determine in the computer-readable memory that mode works so that the instruction being stored in the computer-readable memory, which is produced, to be included referring to Make the manufacture of device, the command device realize in one flow of flow chart or multiple flows and/or one square frame of block diagram or The function of being specified in multiple square frames.
These computer program instructions can be also loaded into computer or other programmable data processing devices so that in meter Series of operation steps is performed on calculation machine or other programmable devices to produce computer implemented processing, thus in computer or The instruction performed on other programmable devices is provided for realizing in one flow of flow chart or multiple flows and/or block diagram one The step of function of being specified in individual square frame or multiple square frames.
In a typical configuration, computing device includes one or more processors (CPU), input/output interface, net Network interface and internal memory.
Memory potentially includes the volatile memory in computer-readable medium, random access memory (RAM) and/ Or the form, such as read-only storage (ROM) or flash memory (flash RAM) such as Nonvolatile memory.Memory is that computer-readable is situated between The example of matter.
Computer-readable medium includes permanent and non-permanent, removable and non-removable media can be by any method Or technology realizes information Store.Information can be computer-readable instruction, data structure, the module of program or other data. The example of the storage medium of computer includes, but are not limited to phase transition internal memory (PRAM), static RAM (SRAM), moved State random access memory (DRAM), other kinds of random access memory (RAM), read-only storage (ROM), electric erasable Programmable read only memory (EEPROM), fast flash memory bank or other memory techniques, read-only optical disc read-only storage (CD-ROM), Digital versatile disc (DVD) or other optical storages, magnetic cassette tape, the storage of tape magnetic rigid disk or other magnetic storage apparatus Or any other non-transmission medium, the information that can be accessed by a computing device available for storage.Define, calculate according to herein Machine computer-readable recording medium does not include temporary computer readable media (transitory media), such as data-signal and carrier wave of modulation.
A kind of STW detection methods, device and equipment provided herein are described in detail above, to disclosed Embodiment described above, professional and technical personnel in the field is realized or use the application.To many of these embodiments Plant modification to will be apparent for those skilled in the art, generic principles defined herein can be not In the case of departing from spirit herein or scope, realize in other embodiments.Therefore, the application is not intended to be limited to this These embodiments shown in text, and it is to fit to the most wide scope consistent with features of novelty with principles disclosed herein.

Claims (9)

1. a kind of STW detection methods, it is characterised in that including:
The initial address difference for obtaining the first object between pointer address when the second object is each created, wherein, it is described First object and second object are respectively the strongly reference object being pre-created, and first object and second object At least one the 3rd object is also pre-created between respective pointer address, the 3rd object is weak reference object;
Obtain first object and the respective current pointer address of second object;
Based on first object and the respective current pointer address of second object, first object and described the are obtained Current address difference between two objects;
The initial address difference is compared with the current address difference, comparison result is obtained;
When the comparison result meets default address distance change condition, the detection that STW is likely to occur in the JVM is generated As a result.
2. according to the method described in claim 1, it is characterised in that the address distance change condition is:First object Address distance between second object changes;
The comparison result meets default address distance change condition, including:
The comparison result shows the initial address difference and current address difference ratio of first object and second object To inconsistent.
3. according to the method described in claim 1, it is characterised in that the acquisition first object and second object are each From current pointer address, including:
Using JNI methods, first object and the respective current pointer address of second object are obtained.
4. according to the method described in claim 1, it is characterised in that described each based on first object and second object From current pointer address, obtain the current address difference between first object and second object, including:
The value of the current pointer address of second object is subtracted to the value of the current pointer address of first object, obtained To value subtraction result;
Take the absolute value of the value subtraction result poor as the current address between first object and second object Value.
5. a kind of STW detection means, it is characterised in that including:
It is first between initial difference acquiring unit, pointer address when being each created for the first object of acquisition and the second object Beginning difference in address, wherein, first object and second object are respectively the strongly reference object being pre-created, and described the At least one the 3rd object, described 3rd pair have also been pre-created between one object and the respective pointer address of the second object As for weak reference object;
Address acquisition unit, for obtaining first object and the respective current pointer address of second object;
Current difference acquiring unit, for based on first object and the respective current pointer address of second object, obtaining Take the current address difference between first object and second object;
Difference comparing unit, for the initial address difference to be compared with the current address difference, obtains comparing knot Really;
As a result generation unit, for when the comparison result meets default address distance change condition, generating in the JVM It is likely to occur STW testing result.
6. device according to claim 5, it is characterised in that the address distance change condition is:First object Address distance between second object changes;
The result generation unit specifically for:Show first object with second object initially in comparison result When location difference compares inconsistent with current address difference, the testing result that STW is likely to occur in the JVM is generated.
7. device according to claim 5, it is characterised in that the address acquisition unit specifically for:Utilize JNI side Method, obtains first object and the respective current pointer address of second object.
8. device according to claim 5, it is characterised in that the current difference acquiring unit includes:
Magnitude calculation subelement, for the value of the current pointer address of second object to be subtracted into working as first object The value of prior pointer address, obtains value subtraction result;
Take absolute value subelement, for taking the absolute value of the value subtraction result as first object and described second pair Current address difference as between.
9. a kind of STW detection devices, it is characterised in that including:
Memory, for storing application program and the produced data of application program operation;
Processor, for performing the application program, to realize following functions:The first object is obtained each to be created with the second object Initial address difference between pointer address when building, wherein, first object and second object are respectively advance wound Also it has been pre-created at least between the strongly reference object built, and first object and the respective pointer address of the second object One the 3rd object, the 3rd object is weak reference object;Obtain first object and second object it is respective work as Prior pointer address;Based on first object and the respective current pointer address of second object, first object is obtained With the current address difference between second object;The initial address difference is compared with the current address difference It is right, obtain comparison result;When the comparison result meets default address distance change condition, generating may in the JVM There is STW testing result.
CN201710128832.5A 2017-03-06 2017-03-06 STW detection method, device and equipment Active CN106951306B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710128832.5A CN106951306B (en) 2017-03-06 2017-03-06 STW detection method, device and equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710128832.5A CN106951306B (en) 2017-03-06 2017-03-06 STW detection method, device and equipment

Publications (2)

Publication Number Publication Date
CN106951306A true CN106951306A (en) 2017-07-14
CN106951306B CN106951306B (en) 2020-01-03

Family

ID=59466953

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710128832.5A Active CN106951306B (en) 2017-03-06 2017-03-06 STW detection method, device and equipment

Country Status (1)

Country Link
CN (1) CN106951306B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1808434A (en) * 2006-01-26 2006-07-26 无锡永中科技有限公司 Object memory store based object reference method
CN101246440A (en) * 2007-02-12 2008-08-20 东信和平智能卡股份有限公司 Java card system rubbish recovering method
CN101281458A (en) * 2008-05-14 2008-10-08 华为技术有限公司 Apparatus, system and for recycling rubbish
CN102270134A (en) * 2011-08-09 2011-12-07 北京握奇数据系统有限公司 Method and device for recycling garbage in Java card
US20160253103A1 (en) * 2015-02-27 2016-09-01 International Business Machines Corporation Tuning utilization and heap memory size for real-time garbage collection

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1808434A (en) * 2006-01-26 2006-07-26 无锡永中科技有限公司 Object memory store based object reference method
CN101246440A (en) * 2007-02-12 2008-08-20 东信和平智能卡股份有限公司 Java card system rubbish recovering method
CN101281458A (en) * 2008-05-14 2008-10-08 华为技术有限公司 Apparatus, system and for recycling rubbish
CN102270134A (en) * 2011-08-09 2011-12-07 北京握奇数据系统有限公司 Method and device for recycling garbage in Java card
US20160253103A1 (en) * 2015-02-27 2016-09-01 International Business Machines Corporation Tuning utilization and heap memory size for real-time garbage collection

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
DEVDIV移动开发社区: "Java的垃圾回收机制", 《ANDROID开发实战体验》 *

Also Published As

Publication number Publication date
CN106951306B (en) 2020-01-03

Similar Documents

Publication Publication Date Title
US9529692B2 (en) Memory management tools
CN107809467B (en) Method for deleting container mirror image data in cloud environment
CN105260294A (en) Monitoring method and device for memory occupied by application program
US20230115491A1 (en) Information presentation method and apparatus, electronic device, and storage medium
US10860454B2 (en) Analyzing large-scale data processing jobs
US11416375B2 (en) Providing additional stack trace information for time-based sampling in asynchronous execution environments
CN108363657A (en) Monitoring APP clients bury method, equipment and the medium of point data acquisition integrality
CN106095413B (en) A kind of configuration method and device of bluetooth driver
US20180150536A1 (en) Instance-based distributed data recovery method and apparatus
US11556468B2 (en) Multi-ring shared, traversable, and dynamic advanced database
US20170244595A1 (en) Dynamic data collection profile configuration
US10241895B2 (en) Memory stack trace management tool
CN109542719A (en) Thread state monitoring method and device, computer equipment and storage medium
CN107395594A (en) A kind of automatic identifying method for pulling identifying code
CN108718307B (en) Behavior tracing detection method for internal threats under IaaS cloud environment
CN111414228B (en) Method and related device for managing storage space based on Kubernetes
CN107526627A (en) A kind of virtual resource life cycle information management method and device
CN108829391A (en) Control recognition methods and system in a kind of Fragment
US9436575B2 (en) Selective profiling of applications
CN106951306A (en) A kind of STW detection methods, device and equipment
CN104778087B (en) A kind of information processing method and information processing unit
CN108874543A (en) A kind of container cluster management method and system
CN109542672A (en) Method and apparatus for recycling the memory block in snapshot storage space
US9760388B1 (en) Memory monitoring tool
CN107040564A (en) Method of data synchronization, data synchronization server and the cloud storage system of cloud storage

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