System and method for solving memory leak in proxy mode

A technology of memory leakage and proxy mode, applied in the field of Java, can solve the problems of memory leakage of objectA and objectB objects, inconvenient to write code, and objectA objects cannot be released in time.
CN110457152AActive Publication Date: 2019-11-15贵阳语玩科技有限公司

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
贵阳语玩科技有限公司
Publication Date
2019-11-15

Smart Images

  • Figure 1
    Figure 1
  • Figure 2
    Figure 2
Patent Text Reader

Abstract

The invention discloses a system and method for solving memory leak by using an agent mode, and the system comprises a judgment module which is used for judging two non-static internal classes with astrong reference relation, wherein at least one non-static internal class is a non-static internal class with a long life cycle; an agent module is used for inserting an agent non-static internal class between the two non-static internal classes; a strong reference setting module used for setting a strong reference relationship between a non-static internal class and an agent non-static internalclass with a long life cycle; and a weak reference setting module used for setting a weak reference relationship between the agent non-static internal class and the other non-static internal class except the non-static internal class with the long life cycle. The mutual strong reference of the external class and the internal class is relieved by utilizing the agent mode and the weak reference object, so that the writing convenience of the non-static internal class is kept.
Need to check novelty before this filing date? Find Prior Art

Description

technical field

[0001] The invention relates to the technical field of Java, in particular to a system and a method for solving memory leaks by using a proxy mode. Background technique

[0002] In Java, non-static inner classes can cause memory leaks. The general solution is to change non-static inner classes to static inner classes. But this solution will reduce the convenience of writing code. In development, it is often necessary to write an anonymous inner class, which is a kind of non-static inner class. If you want to change the anonymous inner class to a static inner class, you can write code. inconvenient.

[0003] Such as figure 1 As shown, objectA is a leaked memory object, its type is OuterClass, which represents the outer class, and InnnerClass is its non-static inner class; Refer to the objectA object; just this will not cause memory leaks. The most important thing is that objectB is strongly referenced by an object objectC with a longer life cycle. When the ...

Claims

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to View More